kevinlawler/kona — Issue #151: Bug with large modulo term?
Author: hakank
Created: 2011-11-21 17:34:16+00:00
State: open

I'm trying to implement the Rosetta Code task "Linear_congruential_generator" http://rosettacode.org/wiki/Linear_congruential_generator and got some strange results.

The first terms of the BSD generator should be this (with a seed of 0)

(0) 12345 1406932606 654583775 1449466924

However, this straightforward implementation

4{((1103515245*x)+12345)!(_2^31)}\0

gives this sequence instead. The first three terms are correct, but the fourth (654583808) is wrong:
it should be 654583775.

0 12345 1406932606 654583808 1358247936

Manually calculating the third step give the same result as in the sequence

((1103515245*1406932606)+12345)!(_2^31)
654583808

Is it the very large modulo term that does this?

Note: Substituting 2^31 with the integer value 2147483648 has the same problem:

10{((1103515245*x)+12345)!(2147483648)}\0

System:
- Main Kona with the latest Git pull (as of some minutes ago)
- Ubuntu 11.10 64-bit, with gcc version "gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1"