This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.

612. numeric_limits::is_modulo insufficiently defined

Section: 17.3.5.2 [numeric.limits.members] Status: CD1 Submitter: Chris Jefferson Opened: 2006-11-10 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [numeric.limits.members].

View all issues with CD1 status.

Discussion:

18.2.1.2 55 states that "A type is modulo if it is possible to add two positive numbers together and have a result that wraps around to a third number that is less". This seems insufficient for the following reasons:

  1. Doesn't define what that value received is.
  2. Doesn't state the result is repeatable
  3. Doesn't require that doing addition, subtraction and other operations on all values is defined behaviour.

[ Batavia: Related to N2144. Pete: is there an ISO definition of modulo? Underflow on signed behavior is undefined. ]

[ Bellevue: accept resolution, move to ready status. Does this mandate that is_modulo be true on platforms for which int happens to b modulo? A: the standard already seems to require that. ]

Proposed resolution:

Suggest 17.3.5.2 [numeric.limits.members], paragraph 57 is amended to:

A type is modulo if, it is possible to add two positive numbers and have a result that wraps around to a third number that is less. given any operation involving +,- or * on values of that type whose value would fall outside the range [min(), max()], then the value returned differs from the true value by an integer multiple of (max() - min() + 1).