Movement against float.init being nan
claptrap
clap at trap.com
Sun Aug 21 09:01:58 UTC 2022
On Sunday, 21 August 2022 at 03:41:55 UTC, Walter Bright wrote:
> I forgot to add that 0.0 is such a common floating point value,
> its erroneous use cannot be reliably distinguished from valid
> uses. Just finding a 0 is not good enough, but finding a NaN is.
This is a complete misrepresentation. It's not that you find 0s
and say oh well it shouldn't be zero here. It's that your results
are wrong, stuff on screen isn't where it should be, your data
plots are off, it's not doing what it should be etc..
If you're doing some numerical computation and you cant tell when
the results are wrong then you almost always doing you're doing
something wrong anyway.
The point is, at least in my experience, and I do a lot of DSP
and statistics stuff, you know the result is wrong and you just
chase it backwards, its the same process whether it's a NaN or
just a wrong result.
And the fact is if you'd just disallowed default initialisation
it would have caught this bug every time for me, and I wouldn't
have just stuck zero in, because the bug is that I forgot to set
the value, not that I didn't know what it was.
So from my experience the rational is based on two fallacies.
1. That using zero as default init would hide the bug.
2. That people will just stick zero in because they don't know
what it should be.
More information about the Digitalmars-d
mailing list