Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/xsaddPublic

JavaScript implementation of the XORSHIFT-ADD (XSadd) pseudo random number generator

License

NotificationsYou must be signed in to change notification settings

mljs/xsadd

Repository files navigation

Zakodium logo

Maintained byZakodium

NPM versionbuild statusnpm download

JavaScript implementation of the XORSHIFT-ADD (XSadd) pseudo random number generator.

Based on the C code fromhttps://github.com/MersenneTwister-Lab/XSadd.

Installation

$ npm install ml-xsadd

API

const{ XSadd}=require("ml-xsadd");constgen=newXSadd();constnumber=gen.getFloat();

new XSadd([seed])

Creates a new XSadd instance. Seed is an optional integer that defaults toDate.now().

getUint32()

Returns a 32-bit integer r (0 <= r < 2^32).

getFloat()

Returns a floating point number r (0.0 <= r < 1.0).

random()

LikegetFloat() but dynamically bound to theXSadd instance.
You can use this function externally, likeMath.random:

constxsadd=newXSadd();constrandom=xsadd.random;constnumber=random();

init(seed)

Reinitialize the generator with a new seed.

LICENSE

MIT

About

JavaScript implementation of the XORSHIFT-ADD (XSadd) pseudo random number generator

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp