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

          Issue ID: 24040
           Summary: dmd different to ldc and gcc for ldexp(f)
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nob...@puremagic.com
          Reporter: john.loughran.col...@gmail.com

I am surprised to see the different behaviour from dmd below:


dev@dev:~$ cat testfloat.d
import std.stdio;
static import core.math;
static import core.stdc.math;

static ulong mantissa = 0x8000000000000001UL;

void main() {
    float a =       core.math.ldexp(float(mantissa), -213);
    float b = core.stdc.math.ldexpf(float(mantissa), -213);
    writeln(*cast(uint*)&a);
    writeln(*cast(uint*)&b);
}

dev@dev:~$ dmd -run testfloat.d
1
0
dev@dev:~$ ldmd2 -run testfloat.d
0
0
dev@dev:~$ cat test.cpp
#include <cmath>
#include <iostream>

int main() {
    float p =   ldexp(0x8000000000000001UL, -213);
    float q =   ldexpf(0x8000000000000001UL, -213);
    std::cout << *((unsigned int*)&p) << std::endl;
    std::cout << *((unsigned int*)&q) << std::endl;
}

dev@dev:~$ g++ test.cpp -o test_cpp
dev@dev:~$ ./test_cpp
0
0

--

Reply via email to