[squeakdev] The Trunk: Kernelul.908.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Feb 26 21:10:30 UTC 2015
Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernelul.908.mcz
==================== Summary ====================
Name: Kernelul.908
Author: ul
Time: 26 February 2015, 10:09:05.384 pm
UUID: 89028aaea08b43209c5553b1036a5192
Ancestors: Kernelul.907
Removed the unused variables from Random.
=============== Diff against Kernelul.907 ===============
Item was changed:
Object subclass: #Random
+ instanceVariableNames: 'states index'
+ classVariableNames: 'MTa MTbShifted MTcShifted MTl MTlowerMask MTm MTn MTs MTt MTu MTupperMask MTw MTwFloatMultiplier MTwordMask'
 instanceVariableNames: 'states index seed'
 classVariableNames: 'A M MTa MTbShifted MTcShifted MTl MTlowerMask MTm MTn MTs MTt MTu MTupperMask MTw MTwFloatMultiplier MTwordMask Q R'
poolDictionaries: ''
category: 'KernelNumbers'!
!Random commentStamp: 'ul 2/20/2015 09:44' prior: 0!
I implement the 32bit version of the Mersenne Twister PRNG, using 30bit arithmetic, based on http://www.math.sci.hiroshimau.ac.jp/~mmat/MT/ARTICLES/mt.pdf . The parameters of the generator are stored in class variables prefixed with MT.
Instance Variables
states: <Array>
index: <Integer>
index
 the index of the state, which should be used to generate the next random integer value
states
 an Array holding the internal state of the generator

If you just want a quick random integer, use:
10 atRandom
Every integer interval can give a random number:
(6 to: 12) atRandom
SequenceableCollections can give randomly selected elements:
'pick one of these letters randomly' atRandom
SequenceableCollections also respond to shuffled, as in:
($A to: $Z) shuffled
The correct way to use class Random is to store one in an instance or class variable:
myGenerator := Random new.
Then use it every time you need another number between 0.0 and 1.0 (excluding)
myGenerator next
You can also generate a positive integer
myGenerator nextInt: 10!
More information about the Squeakdev
mailing list
