I am trying to convert an extended precision 80-bit floating-point number (in buffer) to double. The buffer basically contains the contents of the x87 register.
This question helped me get started as I was not familiar with the IEEE standard. In any case, I'm struggling to find useful information about subnormal (or denormalized) numbers in 80-bit format. I know that unlike float32 or float64 it does not have a hidden bit in the mantissa (adding 1.0 is not implied), so one way to find out if the number is normalized is to check if the most significant bit is set in the mantissa. This leaves me with the following question :
From what wikipedia tells me, float32 and float64 point to an abnormal number with a (offset) exponent of 0 and a nonzero mantissa.
- What does this tell me in 80 bit swimming?
- Can 80-bit mantissa floats, 1.0 even have a non-zero indicator?
- Alternatively, do 80-bit floats with a score of 0 even have mantis> = 1.0?
EDIT: I think the question comes down to the following:
Can I expect the FPU to sanitize the exponent and the highest mantissa bit in the x87 register?
If not, which number should convert the result? Should I ignore the exhibitor at all? Or is it qNaN?
EDIT:
I read the FPU section in Intel's Guide (Intel® 64 and IA-32 Architect Software Developer's Guide, Volume 1: Basic Architecture), which was less scary than what I was afraid of. As it turned out, the following values are not defined:
- exponent == 0 + the highest bit mantissa
- exponent! = 0 + mantissa without the highest bit
He does not mention whether these meanings can appear in the wild, and if they are internally transformed. So I actually cleaned out Ollydbg and manually set the bit to the x87 registers. I created ST (0) to contain all the bits set in the exponent, and mantissa 0. Then I did the execution
FSTP QWORD [ESP] FLD QWORD [ESP]
The value stored in [ESP] been converted to signal NaN. After FLD , ST(0) contained quiet NaN.
I think this answers my question. I made the J-16 SDiZ decision because it is the most direct solution (although it does not explicitly explain some of the finer details).
In any case, the case is settled. Thanks to everyone.
pezcode
source share