Floating point in the type system
Atila Neves via Digitalmars-d
digitalmars-d at puremagic.com
Sat Sep 12 08:49:21 PDT 2015
On Saturday, 12 September 2015 at 15:13:27 UTC, Robert wrote:
> 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
What do think is unusual?
Atila
More information about the Digitalmars-d
mailing list