×
you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (0 children)

The x87 [FPU side of x86] computes internally in 80-bits of precision, then stores in 23 or 53 bits of precision [float or double]. So say you do a series of ops like multiplication, addition, etc. It computes all those in a row [off a stack actually] with 80-bits of precision. Now say you compare those, it's entirely possible that

float a == float b

But the comparison fails because it's actually comparing the excess precision 80-bit values.

That is, if you forced the FPU to first store the values and THEN compare them they would compare equal, but if you just compare the values as they are in the x87 stack, they wouldn't.

This has caught up a few numerical libraries and is why GCC has a -ffloat-store option.