Editions Ideas
Dom Disc
dominikus at scherkl.de
Sun Dec 14 13:27:19 UTC 2025
On Sunday, 14 December 2025 at 07:00:33 UTC, Walter Bright wrote:
> On 12/13/2025 6:50 AM, Dom Disc wrote:
>> By the way, why the f*** is cast(bool)nan == true ?!?
>
> It's the IEEE754 floating point standard behavior. NaN is never
> equal to anything else, so cast(bool)NaN is lowered to NaN!=0,
> which is true.
NaN > 0 is false and NaN <= 0 is also false.
One can see this as a contradiction, but it isn't.
So why can not also NaN == 0 and NaN != 0 both be false?
I would consider this IEEE754 compliant.
> IEEE754 compliance is both expected and baked into the CPU
> hardware.
Yup. But it only requires NaN == 0 to be false. It doesn't talk
about NaN != 0 at all.
More information about the Digitalmars-d
mailing list