bigi
JavaScript library to manipulate big integers. Based on jsbn
by Tom Wu
Pronounced either like "big I" or "biggie".
Why?
Crypto currencies such as Bitcoin require performing mathematical operations on very large integers (256 bit). JavaScript only supports integers up to 53 bits.
Install
npm install --save bigi
Example
var BigInteger = require('bigi')
var b1 = BigInteger.fromHex("188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012")
var b2 = BigInteger.fromHex("07192B95FFC8DA78631011ED6B24CDD573F977A11E794811")
var b3 = b1.multiply(b2)
console.log(b3.toHex())
// => ae499bfe762edfb416d0ce71447af67ff33d1760cbebd70874be1d7a5564b0439a59808cb1856a91974f7023f72132
Methods
Instance
add
and
andNot
bitCount
byteCount
byteValue
clearBit
clone
divide
divideAndRemainder
equals
flipBit
gcd
getLowestSetBit
intValue
max
min
modInverse
modPow
multiply
not
or
pow
remainder
setBit
shiftLeft
shiftRight
shortValue
signum
subtract
testBit
toByteArray
toBuffer
toHex
xor
Class
fromBuffer()
fromHex()
Properties
Class
ONE
ZERO
Package
- issues: https://github.com/cryptocoinjs/bigi/issues
- license: BSD
- versioning: addheres to http://semver-ftw.org
Tests
References
- This library looks promising: https://github.com/MikeMcl/bignumber.js
- This follows the official
jsbn
: https://github.com/jasondavies/jsbn - http://www.joseprio.com/blog/2013/04/27/biginteger-libraries-for-js/
- https://groups.google.com/forum/#!topic/bitcoinhackers/5IlDcTq51Y8
- https://github.com/dominictarr/math-buffer