Why do some T.init evaluate to true while others to false?

Basile B. via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 26 08:48:18 PDT 2016


On Thursday, 26 May 2016 at 15:34:50 UTC, ArturG wrote:
> On Thursday, 26 May 2016 at 15:29:52 UTC, Basile B. wrote:
>
>>
>> float.init is not equal to 0.0f. In D FP points values are 
>> initialized to nan (not a number).
>>
>> By the way for strings it works, it's like the array case I 
>> described in the first answer).
>
> yes i guess i tested all/most types and know that float.init is 
> float.nan but why is nan true and not false?

Oh, I'm so sorry ! I totally missed the point of the Q.

float.nan is not a "unique" value. Several values verify "nan" 
(Look at std.math.isNan). So I suppose it's simpler to test for 
nullity. Though with the sign there's also two possible 0...




More information about the Digitalmars-d-learn mailing list