Bug 17185 – Error: number '0x0.0123p-1022' is not representable
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2017-02-15T17:07:40Z
Last change time
2022-11-16T14:47:34Z
Assigned to
No Owner
Creator
Sophie
Comments
Comment #0 by meapineapple — 2017-02-15T17:07:40Z
I had a line of code including `double(0x0.0123p-1022)` which compiled fine on Windows 7 and OSX; note that 0x0.0123p-1022 is representable as a subnormal double. When compiling on linux with dmd v2.073.0 I received a compile error "Error: number '0x0.0123p-1022' is not representable" - which is not correct, because it is representable as a subnormal.
It is possible to write `double(0x0.0123p-1022L)` instead as a workaround.
Parsing subnormal reals e.g. 0x0.0123p-16382L seems to work fine on all three platforms.
Comment #1 by meapineapple — 2017-02-15T18:04:15Z
This occurred when compiling on ubuntu 12.04.04
Comment #2 by uplink.coder — 2017-02-15T19:21:39Z
This occurs because dmd's parser calls strtold from the c runtime to parse floats.
apparently ubuntu 12.04 version of the runtime does mess this up.
Comment #4 by razvan.nitu1305 — 2022-11-16T14:47:34Z
This code:
void main()
{
import std.stdio : writeln;
writeln(double(0x0.0123p-1022)); // Prints 64+64i, should print 64+0i
}
compiles just fine on my machine (Ubunutu 20.04.4).