Stable D version?

kenji hara k.hara.pg at gmail.com
Mon Apr 22 21:50:36 PDT 2013


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 <wfunction at 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130423/6ee98f6f/attachment.html>


More information about the Digitalmars-d mailing list