float price; if (price == float.nan) { // initialized } else { // uninitialized } ... valid ?
Mathias LANG
geod24 at gmail.com
Wed Jun 30 03:51:47 UTC 2021
On Wednesday, 30 June 2021 at 03:32:27 UTC, Vladimir Panteleev
wrote:
> On Wednesday, 30 June 2021 at 03:15:46 UTC, someone wrote:
>> Is the following code block valid ?
>
> Comparison with `nan` always results in `false`:
>
> See section 10.11.5:
>
> https://dlang.org/spec/expression.html#equality_expressions
>
> You can use the `is` operator to perform bitwise comparison, or
> use `std.math.isNaN`.
Side note: That doesn't apply to `if (myFloat)` or
`assert(myFloat);`, unfortunately:
https://issues.dlang.org/show_bug.cgi?id=13489
More information about the Digitalmars-d-learn
mailing list