[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: checking for Not a Number?
- From: "Joe Smith" <unknown_kev_cat@...>
- Date: Tue, 26 Dec 2006 23:51:05 -0500
"Luiz Henrique de Figueiredo" <firstname.lastname@example.org> wrote in message
I've heard this same explanation elsewere too. (Somebody saw this problem in
Apparently, the registers used in the FPU are oversized, and thus
calculations performed there-in have morie bits than the datatype should.
Thus when compairing a value in the register to the truncated value in the
memory, they can be non-equal.
I lack access to the IEEE 754 standard, and cannot make heads or tails of
much of the ISO C standard when it talks about floating point numbers, so
I'm not certain if this behavior violates either standard, but I've seen
this documented more than once.
Directly compairing floating point numbers for equality is *always* a bad
Only if the numbers are supposed to be the same number but are the result
of two different computations.
For example, you can find that a floating point value which is not a
NaN is not equal to itself.
I find this very surprising. And possibily wrong, ie against IEEE 754.
The explanation that followed made no sense to me. It would make sense for
floating point values held in *different* variables, but not for the
variable. It seems to me that the gcc docs is spreading unnecessary FUD.
But I must be missing something...
On the other hand, it is highly unlikely that the code listed would ever be
affected by this, but it is still troubling.