Ninten
Ninten

Reputation: 565

Number types emulation on javascript

I wonder if there is any library to emulate the native type numbers on other languages, like int and double. The library should emulate those types accurately, including overflow.

Every hint will be very appreciated.

EDIT:

I need to implement a Linear Congruential Generator. I can't switch to another RNG, it must be a LCG.

The problem is that multiplication of big numbers gives wrong results, thus messing the sequence.

Upvotes: 0

Views: 254

Answers (1)

Ninten
Ninten

Reputation: 565

You can use a Typed Array. (FF 4+, Chrome 7+, IE 9+, Safari 5.1+)

It have the following subclasses: Int8Array, Uint8Array, Int16Array, Uint16Array,Int32Array, Uint32Array, Float32Array, Float64Array.

For older browsers you can check: Looking for Javascript Typed Arrays emulation library

Hope you find this information helpful

Upvotes: 2

Related Questions