floats default to NaN... why?

dennis luehring dl.soluz at gmx.net
Sat Apr 14 03:45:27 PDT 2012


Am 14.04.2012 07:48, schrieb F i L:
> On Saturday, 14 April 2012 at 05:19:38 UTC, dennis luehring wrote:
>>  Am 14.04.2012 06:00, schrieb F i L:
>>>       struct Foo {
>>>         int x, y;    // ready for use.
>>>         float z, w;  // messes things up.
>>>         float r = 0; // almost always...
>>>       }
>>
>>  how often in your code is 0 or 0.0 the real starting point?
>>  i can't think of any situation except counters or something
>>  where 0 is a proper start - and float 0.0 is in very very few
>>  cases a normal start - so whats your point?
>
> Every place that a structure property is designed to be mutated
> externally. Almost all Math structures, for instance.

if a float or double is initalized with nan - all operations on them 
will result to nan - that is a very good sign for missing "proper" 
initialisation

what does make float default to 0.0 better - does it just feel better?


More information about the Digitalmars-d-learn mailing list