The Joy of Signalling NaNs! (A compiler patch)

Walter Bright newshound1 at digitalmars.com
Thu Mar 19 14:19:16 PDT 2009


Don wrote:
> Walter Bright wrote:
>> Georg Wrede wrote:
>>> Thanks, Don and Walter!!
>>
>> I originally had this in the Digital Mars C compiler years and years 
>> ago. I dropped it and moved away from it because not a single person 
>> noticed or cared about it, plus the standard C spec failed to 
>> distinguish between quiet and signaling nan's.
>>
>> I'm glad to see it actually being of value, and it's a great idea.
> 
> I noticed there was a place in the backend where it was careful to 
> preserve the signallingness <g> of NaNs. So I thought, hmm, someone's 
> been here before.

Like a chicken that still has genes for dinosaur teeth lurking unactivated!

> 
> The key thing that makes it possible is that D initializes all floats to 
> NaN anyway, and since C doesn't do that, it's not as obviously 
> beneficial. By making NaN the default, you've made sure that practically 
> every D user knows about them. I bet that's not the case for C/C++. (I 
> even know numerical analyists who don't know much about them).

You can still know it's not the case for C/C++ given the crappy support 
for nan in modern compilers.



More information about the Digitalmars-d mailing list