csBigInteger.js
This is csBigInteger.js project, a C# BigInteger implementation on JavaScript. The idea is to provide full compatibility with C# Numerics implementation, regarding hexstring format and little-endness. Some auxiliar functions are also provided, regarding Fixed8 format.
Since version 3.0, it is using bn.js
library (https://github.com/indutny/bn.js) to handle big internals.
How to use it
Example
// get library as 'csbiginteger', e.g., CommonJS: "let csbiginteger = require('csbiginteger')"var x1 = "0xff" 16; // -1 in csBigIntegervar bx1 = x1; // get BN.js internalsvar x2 = 5;var bx2 = x2; // get BN.js internalsvar bx3 = bx2; // performs '-1' + '5'bx3; // outputs '4'
Install on web browser
Classic JS:
If you want as ES6 module:
csBigInteger = csbigintegercsBigInteger;csFixed8 = csbigintegercsFixed8;x = 1000;y = 1000;
Install on npm
npm install csbiginteger
const csBigInteger = csBigInteger;var x = 255;x;// "ff00"var y = x + 1;// 256 (JS unsafe number)const BN = ;var z = x;z;// "256" (BN safe number)
For Developers
Tests
npm test
Build Webpack
npm run build
New minor version
npm version minor
Push and Publish
git push origin master --tags
npm publish
Final remarks
Main maintainer is @igormcoelho. Thanks a lot to @snowypowers for the good advices and @ixje on endianess discussions.
MIT License
Copyleft 2018