phobos icon indicating copy to clipboard operation
phobos copied to clipboard

Decimal string parsing isn't IEEE compatible

Open dlangBugzillaToGithub opened this issue 5 years ago • 3 comments

ilyayaroshenko reported this on 2020-06-21T13:57:02Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=20967

CC List

  • bugzilla (@WalterBright)

Description

import std.conv;
void main() {
    assert("1.448997445238699".to!double == 0x1.72f17f1f49aadp0);
}

dlangBugzillaToGithub avatar Jun 21 '20 13:06 dlangBugzillaToGithub

bugzilla (@WalterBright) commented on 2021-03-25T06:32:23Z

Verified this. Left side produces 0x1.72f17f1f49aaep0 but right side is the correct value.

dlangBugzillaToGithub avatar Mar 25 '21 06:03 dlangBugzillaToGithub

Working on it

Aditya-132 avatar Mar 17 '25 19:03 Aditya-132

Catch by mojo:

{
    ulong msdec = 1448997445238699;       
    printf("%a\n", cast(double)(msdec / 1e15)); // 0x1.72f17f1f49aadp+0
}

but

{
    printf("%a\n", cast(double)(1448997445238699UL / 1e15)); // 0x1.72f17f1f49aaep+0
}

cyrusmsk avatar Oct 30 '25 21:10 cyrusmsk