March 06, 2002 Re: reasoning for operator!= | ||||
---|---|---|---|---|
| ||||
Posted in reply to Immanuel Scholz | "Immanuel Scholz" <digital-mars@kutzsche.net> wrote in message news:a62lfc$2top$1@digitaldaemon.com... > I am new to the list, maybe this was answered before.. (sorry, but google seems not to index digitalmars-newsserver?) I've sent google email about that, but so far no reply. > Why this: > double a = double.nan; > double b = 1.0; > if (a == b) > assert (a != b); // assertion failed.. very strange thing, I think... > Maybe to throw some kind of arethmetic_exception in case of comparing nan-doubles instead of this very strange double-!= behaviour? It does it that way because that's the way IEEE 754 specifies the behavior of floating point ops. This has been adopted by C99. Changing it in D would subtly and very obscurely break code. Some things it's just too hard to swim upstream against <g>. |
Copyright © 1999-2021 by the D Language Foundation