[Issue 23521] Bad conversion in double.to!long for values around long.max
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Dec 5 12:35:10 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23521
Nick Treleaven <nick at geany.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |nick at geany.org
--- Comment #1 from Nick Treleaven <nick at geany.org> ---
to!long(double) calls toImpl which just does cast(long). The problem seems to
be that casting a value bigger than 9223372036854775295 to long gives a
negative result:
long l = 9223372036854775296;
assert(l < long.max);
double d = cast(double)l;
assert(cast(long)d > 0); // fails
However C with gcc does the same:
double d = 9223372036854775296L;
assert((long)d > 0); // fails
--
More information about the Digitalmars-d-bugs
mailing list