ldc icon indicating copy to clipboard operation
ldc copied to clipboard

std.conv.to!double wrong in some cases on aarch64

Open John-Colvin opened this issue 2 years ago • 3 comments

v = "0.6".to!double;
writefln!"%x"(*cast(ulong*)&v);

I think the correct answer is 3fe3333333333333, which is what we get on dmd and ldc on x86_64, but ldc on aarch64 (macos) gives 3fe3333333333334

"1234567.89" & "12.3456789" also showed up in testing as different.

John-Colvin avatar Jul 09 '23 14:07 John-Colvin

couldn't this be due to some rounding mode difference?

JohanEngelen avatar Jul 09 '23 16:07 JohanEngelen

Well maybe... but something is definitely off, because strtod gives the right answer (3fe3333333333333).

John-Colvin avatar Jul 09 '23 17:07 John-Colvin

The same result is obtained on Windows (tested with LDC v1.31), so if this is a bug, it's almost certainly in Phobos and related to 64-bit real (on AArch64, only for Apple).

kinke avatar Jul 10 '23 08:07 kinke