On Friday, 18 March 2016 at 23:35:42 UTC, tsbockman wrote:
`ulong.max` and `-1L` are fundamentally different semantically, even with two's complement modular arithmetic.

Different types implies different semantics, but not the literals in isolation.

Under modular arithmetics for an ubyte the literals -128 and 128 both refer to 128. This follows from -128 == 0 - (128). Unfortunately in D, the actual arithmetics is not done modulo 2^8, but modulo 2^32.

So, what we should object to is modular arithmetics over integers as defined in D.

Just because a few operations (addition and subtraction, mainly) can use a common implementation for both, does not change that. Division, for example, cannot be done correctly without knowing whether the inputs are signed or not.

Yes, both multiplication and division change with the type, but you usually don't want signed values in modular arithmetics?

The major flaw is in how D defines arithmetics for integers.

Reply via email to