floating point - nan initializers
Ivan Senji
ivan.senji_REMOVE_ at _THIS__gmail.com
Sun Feb 19 11:06:29 PST 2006
Anders F Björklund wrote:
> Ivan Senji wrote:
>
>> In that case 0 is as bad as anything else. Atleast with nan, a
>> developer may decide to print sum to console and find out that it is
>> nan. But what if the formula is
>> sum = sum*dx + dy; -> this will cause subtle errors if you expected
>> sum to be 1 for example. But you will get some numbers as a result but
>> they are wrong even though you think they are allright, and the next
>> thing you know your D-driven spaceship is falling onto Mars too fast
>> and you are loosing alot of money an thinking: if only that sum was
>> initialized to nan! :)
>
>
> Then again, it's usually better to catch those bugs at compile time ?
>
Compile time would be best. C# compiler does the same thing, and
although it can be a little irritating it is uesfull. Maybe this could
be warning? But it isn't that easy to detect.
More information about the Digitalmars-d
mailing list