06-20-2006 12:57 PM
06-20-2006 01:59 PM
06-20-2006 03:03 PM
Thanks tbob!
I was on the right path but just needed some expert assistance to get the string into a number.
Let me ask if it would be an easier conversion to go from Hex string to ASCII
06-20-2006 03:48 PM
06-20-2006 03:57 PM - edited 06-20-2006 03:57 PM
@tbob wrote:
I noticed that the second substring's first character is not a zero as stated in your definition.
The way I interpreted the problem is that the code should zero out the first bit. You can do that by ANDing it with an appropriate integer. The code in the attached image shows one possibility. There are many ways to do this.
Message Edited by altenbach on 06-20-2006 01:57 PM
06-20-2006 04:13 PM
@jdam wrote:
I have a 16 bit Binary data string (i.e. 0110000110111000) I need to convert to ascii text using the following format.
Of course we need to know exactly how your "16 bit binary" data string actually looks like. Your question is a bit ambiguous.
So far, we have assumed case (1). Case (2) would be trivial. 😉
06-20-2006 04:35 PM
Thank you both for your (Quick!) assistance with providing a solution to the problem.
The data is presented in Hex string format of a 16 bit word. 8 words (16 ASCII Characters) comprise the Target Name in the data. Sometimes the data transmission can get corrupted providing an invalid word which was the case with my original submit. (might have just been a fat finger on the kb)
Here are 8 words that comprise the following message KNID/T192023
19278, 18756, 12116, 12601, 12848, 12851, 8224, 8224
06-20-2006 05:01 PM
06-20-2006 05:15 PM - edited 06-20-2006 05:15 PM
@jdam wrote:
Here are 8 words that comprise the following message KNID/T192023
19278, 18756, 12116, 12601, 12848, 12851, 8224, 8224
Your 8 words should give 16 characters. The last four must be spaces because there are only 12 characters in KNID/T192023. Also you stated that the data is in hex, but your 8 words are obviously in decimal. Anyway, here is a vi to decipher the words.
Once again Altenbach has to come up with a simpler way to do things. Maybe I should send him all my work for reveiw.
Message Edited by tbob on 06-20-2006 04:16 PM
06-21-2006 10:43 AM
OK,
tbob and altenbach - You guys make this stuff seem too easy.
Let me pose a new problem - I've already devised a solution but I'd like to see how either of you would approach the problem.
The simplest solution wins a prize! I'll send Two Product Patches to the solution that I like the best. Good Luck!
This is a signed 2's comp problem to describe position (North is positive and south is negative). Input is 2 word hex decimal string array.
The bits are laid out with MSB at the left.
MSB = 2^-1, LSB = 2^-31, Max/Min Value is +/- 5.0000E-01, Resolution 4.6566E-10
2 word message
Field name BIT NO
MSW -00- S Sign
-01- N MSB
-02- N .......-15-N
LSW -00-N .......-14-N
-15-N LSB