https://issues.dlang.org/show_bug.cgi?id=18927
Simen Kjaeraas <simen.kja...@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |simen.kja...@gmail.com Resolution|--- |INVALID --- Comment #2 from Simen Kjaeraas <simen.kja...@gmail.com> --- Beyond 16777216, not all integers are representable in a float, and 9007199254740992L is the same threshold for a double. This is because of how the floating-point formats are designed, and not a language issue. Previous behavior loses information and is bug prone, and a failure to compile gives immediate feedback that the programmer is doing something wrong, and does not generate invalid code. For workarounds, T n = cast(T)20_000_001; works, as does 20_000_001.0, as you've pointed out. This test shows the actual limits: unittest{ static assert( __traits(compiles, { float a = 16777216; })); static assert(!__traits(compiles, { float b = 16777217; })); static assert( __traits(compiles, { double d = 9007199254740992L; })); static assert(!__traits(compiles, { double d = 9007199254740993L; })); } --