[OT] The Usual Arithmetic Confusions
Paul Backus
snarwin at gmail.com
Fri Feb 4 22:22:41 UTC 2022
On Friday, 4 February 2022 at 22:11:10 UTC, Steven Schveighoffer
wrote:
> I don't think anyone is arguing that the result of the
> operation should be truncated to a byte, even if assigned to an
> int.
And yet, that's exactly what happens if you use `int` and `long`:
int a = int.max;
long b = a + 1;
writeln(b > 0); // false
I think there are reasonable arguments to be made on both sides,
but having both behaviors in the same language is a bit of a
mess, don't you think?
More information about the Digitalmars-d
mailing list