@japan-d2/random-bigint
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

random-bigint

A random number generator that generates random BigInt with the specified seed and maximum value using Xorshift.

install

npm install @japan-d2/random-bigint

or

yarn add @japan-d2/random-bigint

example

import { RandomGenerator } from '@japan-d2/random-bigint'

const random = new RandomGenerator({
  seed: BigInt(123456789), // accepts any positive integer
  limit: BigInt(10) ** BigInt(64) // for example, 64 digits maximum
})

random.next()
// => 5637762571260449273030132647656691852295390566410681230793181046n
random.next()
// => 4457241536950578442517528619126578343447503233842310925555103992n
random.next()
// => 9489098265339258643990268960842203575162730303587018422124828169n
random.next()
// => 5945162572438736028849931049929240611671488712663034771122619621n

classes

class RandomGenerator

new RandomGenerator (options: Options)

Options
seed: bigint

seed for random generator.

limit: bigint

limit of random values.

discards: number

discard first n values. (default = 100)

next (): bigint

returns random value and advance the state of the generator.

look (): bigint

look the next random number without changing the state of the generator

license

MIT

Readme

Keywords

Package Sidebar

Install

npm i @japan-d2/random-bigint

Weekly Downloads

0

Version

0.0.5

License

MIT

Unpacked Size

5.52 kB

Total Files

5

Last publish

Collaborators

  • tatat
  • uneco