Movement against float.init being nan

bauss jacobbauss at gmail.com
Thu Aug 25 09:18:11 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 ?

It could be optimized away in release code and/or be optional to 
disable (should be enabled by default.)


More information about the Digitalmars-d mailing list