Skip to content

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

NameTypeDefault valueDescription
seednumber0Random seed

Returns

Rand

Defined in

src/math/Rand.ts:18

Accessors

seed

get seed(): number

Random seed

Returns

number

Defined in

src/math/Rand.ts:25

set seed(value): void

Parameters

NameType
valuenumber

Returns

void

Defined in

src/math/Rand.ts:29

Methods

getFloatFromInt

getFloatFromInt(value): number

Convert an integer to a floating-point number

Parameters

NameTypeDescription
valueanyinteger

Returns

number

Defined in

src/math/Rand.ts:41


getByteFromInt

getByteFromInt(value): number

Converts an integer to a single-byte integer

Parameters

NameTypeDescription
valueanyinteger

Returns

number

Defined in

src/math/Rand.ts:51


clone

clone(): Rand

Returns a new random number generator object with the same seed state as the current random number generator object

Returns

Rand

Defined in

src/math/Rand.ts:61


get

get(): number

Generate a random number

Returns

number

Defined in

src/math/Rand.ts:74


getFloat

getFloat(): number

Randomly generate a floating-point number 0.0 to 1.0

Returns

number

Defined in

src/math/Rand.ts:86


getSignedFloat

getSignedFloat(): number

Randomly generates signed floating-point numbers -1.0 to 1.0

Returns

number

Defined in

src/math/Rand.ts:94

Released under the MIT License