Three floating point questions

bearophile bearophileHUGS at lycos.com
Wed Aug 25 17:38:46 PDT 2010


Don:
> > Do you know what cast(ulong) is doing here?
> 
> Turning it from a signalling nan to a quiet nan.

I really really didn't know this. Is this written somewhere in the D docs? :-)


> You mean, because it's a negative nan?

Yes, I mean that. Is a negative nan a meaningful concept? Is it a true negative nan coming from the division of two positive values, or it's just a bug of writeln, or is it something completely different?


> The signalling nans get triggered in the 'double x; ' line.

(You are often two steps forward compared to my thought patterns, so please be patient with me)
In this program the FP register is modified after that definition line, so I don't expect 'double x; ' to trigger an hardware exception.
But the 'double r = x * d3;' line computes the product of a signaling nan and a normal double, so this is an operation that has to produce an error, I think.


> This happens because there's a difference in the way AMD and Intel deal 
> with signalling nans, which is completely unpublicised. So my initial 
> testing was inadequate.

I see. If not even official CPU specs show such data, then not being right in the first (and second) implementation is forgiveable, I presume :o)

Bye and thank you,
bearophile


More information about the Digitalmars-d-learn mailing list