Click to See Complete Forum and Search --> : Conversoin of HexString to Double
shivakumarthota
June 10th, 2002, 01:39 AM
I needed to twiddle the value of a Double variable and in the process converted the double value to a hexstring and then maipulated the byte location and stored the hexstring in another string.
Now to convert this hexstring back to Double is become a problem. I tried to use the "strod()" function, but as soon as the function sees an alphabet it terminates giving me an incomplete value.
Please help me convert this hexstring back to a double number
Shivakumar Thota
shivatk@hotmail.com
JMS
June 10th, 2002, 09:51 AM
>> Now to convert this hexstring back to Double is become a
>> problem.
What does this mean? Hexstring? I mean integers are stored as binary memory and that memory can be reformated to octal, hex, or decimal. So I'm not sure what your asking.
maybe you converted an integer to a hex value and stored that value into a string, if you wanted to put it back to an integer then all you'd have to do is use the atoi function on it just like a regular decimal string. The 0x in front of the number tells teh atoi function that it's a hex value.
As for manipulating the characters in a double byte sting. use an int array or an int pointer. int is a double byte character can be used to address such a string.
As for not being able to use regular string commands like strod()" against your double byte string that is understandable. Double byte strings have embedded signle byte null's embedded into them. The termination value is a double null for a double byte string. Thus one would expect regular single byte functions to fail.
Either rewrite the functions using int instead of char, or one could use the double byte library like wstrod()..... I think that's the name check it out.
shivakumarthota
June 10th, 2002, 02:28 PM
Originally posted by JMS
>> Now to convert this hexstring back to Double is become a
>> problem.
What does this mean? Hexstring? I mean integers are stored as binary memory and that memory can be reformated to octal, hex, or decimal. So I'm not sure what your asking.
maybe you converted an integer to a hex value and stored that value into a string, if you wanted to put it back to an integer then all you'd have to do is use the atoi function on it just like a regular decimal string. The 0x in front of the number tells teh atoi function that it's a hex value.
As for manipulating the characters in a double byte sting. use an int array or an int pointer. int is a double byte character can be used to address such a string.
As for not being able to use regular string commands like strod()" against your double byte string that is understandable. Double byte strings have embedded signle byte null's embedded into them. The termination value is a double null for a double byte string. Thus one would expect regular single byte functions to fail.
Either rewrite the functions using int instead of char, or one could use the double byte library like wstrod()..... I think that's the name check it out.
Thank you very much JMS your idea did help me a get a good lead to finish my program
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.