O
oddstray
Hi,
I have a number which is larger than the max unsigned long int. I
don't have 64-bit integers available to me. I need to get the
resulting 40-bit hex string.
I can't find any algorithm or solution when I search the web. I've
seen a couple of suggestions searching Usenet, but neither of them
works. One tried to use a union, and the other tried to convert each
byte of the float.
There are a few open-source large-value math libraries, but none of
them seems to include float-to-hex-string conversion. (And I find
open-source nearly impossible to build and understand and use anyway.)
I have an algorithm which works, but seems alarmingly baroque ... so
I'm hoping there's a more straightforward way. It divides the large
value by six, converts the sixths to hex strings, and then six times
does a character-by-character addition to construct the final hex
string.
It seems that some sort of bit magic should be possible, but if I ever
knew enough about how floats are rendered I've long since forgotten
it. Possibly it's machine-dependent, anyway.
Can anyone offer any enlightenment? Is my baroqe algorithm really the
best one? Thanks in advance ...
B
I have a number which is larger than the max unsigned long int. I
don't have 64-bit integers available to me. I need to get the
resulting 40-bit hex string.
I can't find any algorithm or solution when I search the web. I've
seen a couple of suggestions searching Usenet, but neither of them
works. One tried to use a union, and the other tried to convert each
byte of the float.
There are a few open-source large-value math libraries, but none of
them seems to include float-to-hex-string conversion. (And I find
open-source nearly impossible to build and understand and use anyway.)
I have an algorithm which works, but seems alarmingly baroque ... so
I'm hoping there's a more straightforward way. It divides the large
value by six, converts the sixths to hex strings, and then six times
does a character-by-character addition to construct the final hex
string.
It seems that some sort of bit magic should be possible, but if I ever
knew enough about how floats are rendered I've long since forgotten
it. Possibly it's machine-dependent, anyway.
Can anyone offer any enlightenment? Is my baroqe algorithm really the
best one? Thanks in advance ...
B