Movement against float.init being nan
Dukc
ajieskola at gmail.com
Fri Aug 26 21:34:51 UTC 2022
On Thursday, 25 August 2022 at 17:38:25 UTC, Steven Schveighoffer
wrote:
> ```d
> if(val > maxBW) delaySending();
> ```
>
> If `val` or `maxBW` are NaN, this will always be a false
> condition (because of the wonderful property that comparisons
> with NaN are always false), so that code effectively never
> executes. Note that there's no `printf` here, and the code
> happily compiles and runs, it just does something unexepected.
>
> 0 is no better here *but also no worse*.
In hindsight, the robust way to solve this would be that trying
to compare NaN to anything would crash the program.
No way to add that to D without too much breakage though, I'm
afraid.
More information about the Digitalmars-d
mailing list