Jump to content

Talk:Linear congruential generator: Difference between revisions

m
m (→‎When modulus matches the first operand's sign: 'congruential' => 'congruent')
Line 41:
{{alertbox|#ffffd8|These generators can yield negative numbers because the modulus operator of F# matches the sign of the first operand. The generators must only yield numbers from 0 to m - 1.
----
Negative numbers from lcg.bsd are <s>congruential</s> congruent to the correct numbers: -740551042 is <s>congruential</s> congruent to 1406932606. Negative numbers from lcg.ms are off by one, because the division truncated to the wrong direction: -11529 is <s>congruential</s> congruent to 21239, but expected 21238.}}
 
I know of 2 workarounds: (1) use [[bitwise operations]] to clear the sign bit, or (2) check if <code>formula (mod) m</code> is negative, and if so, add <code>m</code>. We might want to clarify the task. --[[User:Kernigh|Kernigh]] 17:21, 1 August 2011 (UTC)
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.