 <p>Unsigned integral types in C++ obey the rules of modular arithmetic, i.e. they represent the integers modulo 2<sup><em>N</em></sup>, where <em>N</em> is the number of value bits of the integral type (possibly less than its <code>sizeof</code> times <code>CHAR_BIT</code>); specifically, the type holds the values [0, 2<sup><em>N</em></sup>).</p> <p>So when you multiply two numbers, the result is the remainder of the mathematical result divided by 2<sup><em>N</em></sup>.</p> <p>The number <em>N</em> is obtainable programmatically via <a href="http://en.cppreference.com/w/cpp/types/numeric_limits/digits" rel="nofollow"><code>std::numeric_limits&lt;T&gt;::digits</code></a>.</p>