Movement against float.init being nan
Nick Treleaven
nick at geany.org
Sat Aug 20 12:30:37 UTC 2022
On Saturday, 20 August 2022 at 11:51:13 UTC, Adam D Ruppe wrote:
> On Saturday, 20 August 2022 at 10:26:08 UTC, Nick Treleaven
> wrote:
>> On Saturday, 20 August 2022 at 03:12:43 UTC, Steven
>> Schveighoffer wrote:
>>> You can't even `assert(x != double.init)`. You have to use an
>>> esoteric function `isNaN` for that.
>>
>> Actually, you can use `is`:
>> ```d
>> static assert(float() is float.nan);
>> ```
>
> That works for float.init specifically, but if you've done some
> operation on it and ended up with a nan, that will not
> necessarily be true since nans come in several bit patterns.
Sorry, so there are other kinds of NaN than T.nan? How do you
produce them? `0F/0F is float.nan` is true.
More information about the Digitalmars-d
mailing list