Bug 16344 – Real FP magic on windows

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-08-01T06:41:00Z
Last change time
2024-12-13T18:49:19Z
Assigned to
No Owner
Creator
Seb
Moved to GitHub: dmd#17769 →

Comments

Comment #0 by greensunny12 — 2016-08-01T06:41:00Z
Consider the following program: void main { import std.stdio; import std.math; alias S = real; S f = 0x1.14ada3f2c1d77p-48; writefln("up: %a", f.nextUp); writefln("down: %a", f.nextDown); writefln("f: %a", f); } On Windows it prints the same number. ``` up: 0x1.14ada3f2c1d77p-48 down: 0x1.14ada3f2c1d77p-48 f: 0x1.14ada3f2c1d77p-48 ``` On Linux for 32-bit as well as 64-bit it prints the expected result: ``` up: 0x8.a56d1f960ebb801p-51 down: 0x8.a56d1f960ebb7ffp-51 f: 0x8.a56d1f960ebb8p-51 ``` If I digged correctly, core.stdc.stdio.fwrite is used under the hood of std.format (and thus writef). Unfortunately I don't have a Windows machine to test this further. From the documentation for '%a': > If there is no Precision, as many hexadecimal digits as necessary to exactly represent the mantissa are generated.
Comment #1 by sprink.noreply — 2016-10-25T03:13:42Z
Windows doesn't have a "real" type, or at least it's standard library doesn't. So if it is using C's write then it is probably using double and not "real" or long double.
Comment #2 by robert.schadek — 2024-12-13T18:49:19Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17769 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB