4.0.3 • Published 4 years ago

csbiginteger v4.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

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 = new csbiginteger.csBigInteger("0xff", 16); // -1 in csBigInteger
var bx1 = x1.asBN(); // get BN.js internals
var x2 = new csbiginteger.csBigInteger(5);
var bx2 = x2.asBN(); // get BN.js internals
var bx3 = bx2.add(bx1); // performs '-1' + '5'
bx3.toString(10); // outputs '4'

Install on web browser

Classic JS:

<script src="https://unpkg.com/csbiginteger/dist/csbiginteger"></script>

If you want as ES6 module:

<script type="module">
import csbiginteger from "https://unpkg.com/csbiginteger/dist/csbiginteger-es6";
</script>
csBigInteger = csbiginteger.csBigInteger;
csFixed8 = csbiginteger.csFixed8;
x = new csBigInteger(1000);
y = new csFixed8(1000);

Install on npm

npm install csbiginteger

const csBigInteger = require('csbiginteger').csBigInteger;
var x = new csBigInteger(255);
x.toHexString();
// "ff00"
var y = x + 1;
// 256 (JS unsafe number)
const BN = require('bn.js');
var z = x.asBN().add(new BN(1));
z.toString(10);
// "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

4.0.3

4 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.0.0

5 years ago

2.14.0

5 years ago

2.13.0

5 years ago

2.12.0

6 years ago

2.11.0

6 years ago

2.10.0

6 years ago

2.9.0

6 years ago

2.8.0

6 years ago

2.7.0

6 years ago

2.6.0

6 years ago

2.5.0

6 years ago

2.4.0

6 years ago

2.3.0

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.3.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago