Movement against float.init being nan

max haughton maxhaton at gmail.com
Thu Aug 25 11:38:22 UTC 2022


On Thursday, 25 August 2022 at 09:07:54 UTC, user1234 wrote:
> On Thursday, 25 August 2022 at 07:15:58 UTC, bauss wrote:
>> On Thursday, 25 August 2022 at 03:08:54 UTC, Steven 
>> Schveighoffer wrote:
>>>
>>> A better option would be to throw an exception if NaN is used 
>>> in an operation.
>>>
>>> -Steve
>>
>> IMHO this is the better solution and not even an exception, 
>> but Error.
>>
>> As soon as you have any NaN values that are being used your 
>> program is effectively useless and broken.
>>
>> I think as soon as any variable becomes NaN it should throw, 
>> not just when an operation happens.
>>
>> Basically I think it should throw when either of these 
>> conditions holds true:
>>
>> - A value was initialized as NaN and used in an operation
>> - A value was set to NaN outside of initialization
>> - NaN is returned from a function (Even if not set to a 
>> variable or anything.)
>
> I'm shocked by this idea. What if I want high performance 
> nothrow FP code ?

Turn the check off. The hardware basically already supports doing 
this (NaNs don't have to be quiet) but almost no one uses it - 
it's quite hard to trigger at all on a modern system.


More information about the Digitalmars-d mailing list