Class: Rand
'Rand' is a random number generator based on an improved xorshift algorithm, which is a modification of the Linear Congruential Generator (LCG) method.
Constructors
Accessors
Methods
Constructors
constructor
• new Rand(seed?
): Rand
Create a random number generator object with a specified seed.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
seed | number | 0 | Random seed |
Returns
Defined in
Accessors
seed
• get
seed(): number
Random seed
Returns
number
Defined in
• set
seed(value
): void
Parameters
Name | Type |
---|---|
value | number |
Returns
void
Defined in
Methods
getFloatFromInt
▸ getFloatFromInt(value
): number
Convert an integer to a floating-point number
Parameters
Name | Type | Description |
---|---|---|
value | any | integer |
Returns
number
Defined in
getByteFromInt
▸ getByteFromInt(value
): number
Converts an integer to a single-byte integer
Parameters
Name | Type | Description |
---|---|---|
value | any | integer |
Returns
number
Defined in
clone
▸ clone(): Rand
Returns a new random number generator object with the same seed state as the current random number generator object
Returns
Defined in
get
▸ get(): number
Generate a random number
Returns
number
Defined in
getFloat
▸ getFloat(): number
Randomly generate a floating-point number 0.0 to 1.0
Returns
number
Defined in
getSignedFloat
▸ getSignedFloat(): number
Randomly generates signed floating-point numbers -1.0 to 1.0
Returns
number