KissRandom class
A pseudo random generator from George Marsaglia. https://de.wikipedia.org/wiki/KISS_(Zufallszahlengenerator) The algorithm is modified to support JavaScript ("Web") with float arithmetic only:
- each state calculation is restricted to a 32 bit value.
- multiplication is restricted to 52 Bit (mantissa in IEEE-754)
- each multiplication operand is restricted to 26 bit. Period length: 2**124 near 2.12E37 Small state vector (4 int values) https://github.com/dworthen/prng/blob/master/support/js/Xorshift03.js
- Inheritance
-
- Object
- BaseRandom
- KissRandom
Constructors
- KissRandom(BaseLogger logger)
Properties
- addParam ↔ int
-
getter/setter pair
- c ↔ int
-
getter/setter pair
- factorParam ↔ int
-
getter/setter pair
- factorParam2 ↔ int
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- id ↔ int
-
getter/setter pairinherited
- logger → BaseLogger
-
finalinherited
-
resetState
↔ List<
int> -
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- x ↔ int
-
getter/setter pair
- y ↔ int
-
getter/setter pair
- z ↔ int
-
getter/setter pair
Methods
-
byteList(
int length) → List< int> -
Returns a list of random bytes with a given
length
.inherited -
maskFactor(
int factor) → int -
Removes the most significant bits from an multiply operand.
Needed on restricted arithmetic.
override
-
maskOperand(
int operand) → int -
Removes the most significant bits from an addition operand.
Needed on restricted arithmetic.
override
-
next(
) → int -
Calculates the next seed.
override
-
nextDouble(
) → double -
Returns a random double with 0 <= rc < 1.
inherited
-
nextInt(
{int max = MaxInt, int min = 0}) → int -
Returns a random integer with 0 <= rc <
max
.inherited -
nextString(
int length, [CharClass charClass = CharClass.chars96, String? charList]) → String -
Returns a random string with a given
length
.charClass
: defines the characters of the result.charList
is null or a string with all allowed characters. @throws FormatException ifcharClass
is custom andcharList
is null.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void -
Sets the state to a well known state: the start state or the state of the
last call of setStart()
inherited
-
restoreState(
List< int> list) → void -
override
-
saveState(
) → List< int> -
override
-
setResetState(
) → void -
Sets the state used in reset().
Must be called in the constructor of each overloading class.
inherited
-
setSeed(
String passphrase) → void -
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- FactorMask → const int
- IntMask → const int