http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51795

--- Comment #19 from spoon.reloaded at gmail dot com 2012-01-27 21:21:40 UTC ---
Paulo, in response to your suggestion to simply do multiplication and modulo in
#7 and #8, I don't think that would work in general. The example I gave
happened to have m = a power of 2 (namely 2^31), and so the truncation that we
would get from integer overflow (whether by 2^32 if we use uint32_t or 2^64 if
we use uint64_t) does not affect the result. However, if we choose any other
number as a modulo (e.g. 2^31 - 1) and say we use uint32_t as the type, it will
not work:

(1103515245 * 1103527590 + 12345) % 2147483647 = 944465040

but in uint32_t arithmetic:

(1103515245 * 1103527590 + 12345) % (1 << 32) % 2147483647 = 377401576

This is why I think we still need something like the Schrage's algorithm

Reply via email to