Floating point in the type system

Robert via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 12 08:13:26 PDT 2015


Hi all,

I came across this example, and wondered what your thoughts on it 
are:


```
void main(string[] args)
{
     struct Foo(float f) {
         alias VAL = f;
         float getF() {
             return f;
         }
     }

     Foo!(float.nan) f;
     Foo!(float.nan) f2;

     // This will fail at compile time
     static assert(f.VAL == f2.VAL);

     // This will fail at run time
     assert(f.getF() == f2.getF());

     // But this is ok
     f = f2;
}
```

It seems a little unusual to me.

Robert


More information about the Digitalmars-d mailing list