I mean, for example, I have the following number encoded in IEEE-754 single precision:
"0100 0001 1011 1110 1100 1100 1100 1100" (approximately 23.85 in decimal)
The binary number above is stored in a literal string.
The question is, how can I convert this string to an IEEE-754 double-precision representation (somewhat similar to the following, but the value is not the same) WITHOUT loss of precision?
"0100 0000 0011 0111 1101 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1010"
which is the same number encoded in double precision by IEEE-754.
I tried using the following algorithm to convert the first string to a decimal number first, but it loses accuracy.
num in decimal = (sign) * (1 + frac * 2^(-23)) * 2^(exp - 127)
I am using the Qt C ++ Framework on a Windows platform.
EDITOR: I have to apologize, maybe I didn’t get a clear question. I mean, I do not know the true value of 23.85, I only have the first line, and I want to convert it to a double-precision representation without losing accuracy.
Richard
source share