floats default to NaN... why?

Jerome BENOIT g6299304p at rezozer.net
Sat Jun 9 11:48:15 PDT 2012



On 09/06/12 20:42, Minas wrote:
>> With
>> ints, the best we can do is 0. With floats, NaN makes it better.
>
> With the logic that NaN is the default for floats, 0 is a very bad choice for ints. It the worst we could do. Altough I understand that setting it to something else like -infinity is still not a good choice.
>

Do you ave in mind something as NaI (Nat an Integer) ?

> I think that if D wants people to initialize their variables, it should generate a compiler error when not doing so, like C# and Java. For me, having floats defaulting to NaN and ints to zero is somewhere in the middle... Which isn't good.
>
> The current solution is not good for me (I still love D though).
>
>

Jerome


More information about the Digitalmars-d-learn mailing list