From the standard (C11, 6.2.5/9, emphasis mine):
[...] A computation involving unsigned operands can never overflow,
because a result that cannot be represented by the resulting unsigned integer type is
reduced modulo the number that is one greater than the largest value that can be
represented by the resulting type.
If UINT_MAX
is 10
:
(10 + 1) % (10 + 1) == 0
So, yes, it's safe to assume it's zero.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…