
15 Mar
2017
15 Mar
'17
9:40 p.m.
degski wrote:
Because I think the idea is flawed from the start.
int x = 2 * 2;
is wrong in principle, correct would be:
int64_t x = 2 * 2;
That's what the library does (in 'automatic' promotion mode, which should be only mode in my opinion.) When you multiply two integers, one having range [0, M] and the other having range [0,N], you get an integer with range [0, M*N]. So safe<uint32_t> * safe<uint32_t> gives safe<uint64_t> (almost).