It is possible to substract 5 from 3 unsigned integer

Mike Parker aldacron at gmail.com
Tue Oct 6 14:20:53 UTC 2020


On Tuesday, 6 October 2020 at 12:24:56 UTC, Alaindevos wrote:
> Is that the expected behavior of the programmer?
> Opinions can differ. Feel free to elaborate.

It's expected behavior:

"If both operands are of integral types and an overflow or 
underflow occurs in the computation, wrapping will happen. For 
example, uint.max + 1 == uint.min, uint.min - 1 == uint.max, 
int.max + 1 == int.min, and int.min - 1 == int.max."

https://dlang.org/spec/expression.html#add_expressions


More information about the Digitalmars-d-learn mailing list