www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13457] New: float version of isIdentical fails

https://issues.dlang.org/show_bug.cgi?id=13457

          Issue ID: 13457
           Summary: float version of isIdentical fails
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: ilyayaroshenko gmail.com

bool isIdentical(float x, float y)  trusted pure nothrow  nogc
{
    // We're doing a bitwise comparison so the endianness is irrelevant.
    int*   pxs = cast(int *)&x;
    int*   pys = cast(int *)&y;
    return pxs[0] == pys[0];
}

unittest {
    float fn1 = NaN(0xABC);
    float fn2 = NaN(0xABC);
    assert(isIdentical(fn1, fn2)); //<--- fails on Darwin_32
}


https://github.com/D-Programming-Language/phobos/pull/2509

--
Sep 10 2014