Floating point in the type system

Xinok via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 12 09:15:32 PDT 2015


On Saturday, 12 September 2015 at 16:08:31 UTC, Robert wrote:
> On Saturday, 12 September 2015 at 15:49:23 UTC, Atila Neves 
> wrote:
>> What do think is unusual?
>>
>> Atila
>
> It's unusual, because `float.nan != float.nan`, so one might 
> expect that `typeof(Foo!(float.nan) != Foo!(float.nan))`, 
> whereas this is clearly not the case, even with both the static 
> assert and runtime assert failing. I'm just curious to 
> understand the reasoning behind this, whether it's intentional, 
> and whether it matters at all.

(1) f = f2; // This is assignment, not comparison
(2) alias VAL = f; // This is not a data member so is not 
involved in comparisons or assignments

change "alias VAL" to "float VAL" and then you might see the 
behavior you expect.


More information about the Digitalmars-d mailing list