In floating point value comparison, +0.0 is equal to -0.0.

    auto x = +0.0;
    auto y = -0.0;
    assert(x == y);

Kenji Hara


2013/4/23 Mehrdad <wfunct...@hotmail.com>

> On Tuesday, 23 April 2013 at 04:33:24 UTC, Chris Cain wrote:
>
>> On Tuesday, 23 April 2013 at 04:27:45 UTC, Mehrdad wrote:
>>
>>> ?!??!
>>>
>>
>> opEquals by default is simply a bit-level value check.
>>
>
>
>
> In fact, it's _doubly_ broken...
>
>         import std.stdio;
>         struct S { float d; }
>         void main()
>         {
>             writeln(+0.0);
>             writeln(-0.0);
>             writeln(S(+0.0) == S(-0.0));
>         }
>
>
> Output:
>         0
>         -0
>         true
>

Reply via email to