Home Manual Reference Source

Usage

The code needs a ES2015+ polyfill to work, for example regenerator-runtime/runtime.

require( 'regenerator-runtime/runtime' ) ;
// or
import 'regenerator-runtime/runtime.js' ;

Then

const integer = require( '@aureooms/js-integer' ) ;
// or
import * as integer from '@aureooms/js-integer' ;

Notation

The Notation tries to emulate the notation in bn.js.

Instructions

Prefixes/postfixes are put in parens at the of the line.

Initialization

Copying

Note that we plan to be pure in the future.

Comparison

Integer Arithmetic

In the future, remove in-place operations. They make very little sense except in a few exceptional cases like increment/decrement. If the result is too big to fit in the original array we will have to resize it to make it fit anyway. Maybe little endianess would save the day in that case. Who knows... Could use an immutable flag that is set as soon as a shallow copy is made? Then all operations could try to run in-place if no shallow copy exists.

Greatest Common Divisor

Modular Arithmetic

Bit operations

We should really have two packages:

There are multiple reasons for this:

Q: Does it make any sense to have those operations defined for unbounded integers?

The following will be implemented in a package to come.

Test

Utilities

Conversion