Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In modwrap semantics (also called modulo arithmetic), integer values "wrap round." That is, adding one to MAX produces MIN. This is the defined behavior for unsigned integers in the C standard [ISO/IEC 9899:2011], Section 6.2.5, paragraph 9. This is frequently the behavior of signed integers, as well. However, it is more sensible in many applications to use saturation semantics instead of modwrap semantics. For example, in the computation of a size (using unsigned integers), it is often better for the size to stay at the maximum value in the event of overflow rather than suddenly becoming a very small value.

...

ISO/IEC TR 24772 "FLC Numeric conversion errors"

Bibliography

[ISO/IEC 9899:2011], Section  Section 6.2.5, "Types"

[Lions 1996]

...