Movement against float.init being nan

Walter Bright newshound2 at digitalmars.com
Sun Aug 21 03:46:13 UTC 2022


On 8/20/2022 11:05 AM, Dom Disc wrote:
> On Saturday, 20 August 2022 at 01:01:07 UTC, Walter Bright wrote:
>> If there was a NaN value for int, I would have used it as the default. int.min 
>> is not really a NaN.
> 
> But it should be!
> int.min is a notorious bogus value. You can't even use abs() on it: it will 
> either give you a different type or return garbage. There is not even a working 
> literal for it (at least for long.min). So it should never have been a valid 
> value from beginning.
> The first thing I include in every of my programs is a module that define 
> exactly that: an alias to byte/short/int/long that takes T.min as invalid value 
> (and uses it as default value) and gives T.min+1 as its real min value.

As soon as an operation is done on it, it isn't int.min anymore. It has some 
characteristics of a NaN, but not enough.


More information about the Digitalmars-d mailing list