Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.1011.mcz==================== Summary ====================
Name: Kernel-ul.1011
Author: ul
Time: 2 April 2016, 9:22:40.391347 pm
UUID: 924b2c29-5e11-4abb-aeb5-355380a4e56a
Ancestors: Kernel-ul.1010
Normalize the created LargePositiveInteger in Random >> #nextLargeInt:.
=============== Diff against Kernel-ul.1010 ===============
Item was changed:
----- Method: Random>>nextLargeInt: (in category 'accessing') -----
nextLargeInt: anInteger
"Answer a random integer value from the interval [1, anInteger]. This method works for arbitrarily large integers."
| byteCount bigRandom result firstDigit |
byteCount := anInteger digitLength + 4. "Extend the space with at least 32 bits for a fairer distribution."
bigRandom := LargePositiveInteger new: byteCount.
self nextBytes: byteCount into: bigRandom startingAt: 1.
+ bigRandom := bigRandom normalize. "Make sure that there are no leading zero bytes."
result := anInteger * bigRandom bitShift: -8 * byteCount.
"Avoid using LargeInteger arithmetic for +1 in most cases."
result isLarge ifFalse: [ ^result + 1 ].
(firstDigit := result digitAt: 1) = 255 ifTrue: [ ^result + 1 ].
result digitAt: 1 put: firstDigit + 1.
^result
!