ldc icon indicating copy to clipboard operation
ldc copied to clipboard

`to!double("0.1") != to!double("0.1000000000000000")` on Windows

Open CyberShadow opened this issue 2 years ago • 1 comments
trafficstars

This program should print 0:

import std.conv;
import std.stdio;

void main()
{
	auto a = to!double("0.1");
	auto b = to!double("0.1000000000000000");
	writeln(a - b);
}

On Windows, this prints 1.38778e-17.

  • Happens with either -m32mscoff and -m64.
  • Doesn't happen with dmd (either -m32mscoff or -m64).
  • I can reproduce this in Wine too.

CyberShadow avatar Jul 20 '23 14:07 CyberShadow

Related (or same?) issue: https://github.com/ldc-developers/ldc/issues/4433

JohanEngelen avatar Jul 20 '23 17:07 JohanEngelen