Work in progress
WebAssembly fixed length big numbers written on AssemblyScript
Provide wide numeric types such as u128, u256, i128, i256 and fixed points and also its arithmetic operations.
Namespace safe contain equivalents with overflow/underflow traps.
All kind of types pretty useful for economical and cryptographic usages and provide deterministic behavior.
Install
yarn add as-bignum
or
npm i as-bignum
Usage via AssemblyScript
import { u128 } from "as-bignum";
declare function logF64(value: f64): void;
declare function logU128(hi: u64, lo: u64): void;
var a = u128.One;
var b = u128.from(-32); // same as u128.from<i32>(-32)
var c = new u128(0x1, -0xF);
var d = u128.from(0x0123456789ABCDEF); // same as u128.from<i64>(0x0123456789ABCDEF)
var e = u128.from('0x0123456789ABCDEF01234567');
var f = u128.fromString('11100010101100101', 2); // same as u128.from('0b11100010101100101')
var r = d / c + (b << 5) + e;
logF64(r.as<f64>());
logU128(r.hi, r.lo);Usage via JavaScript/Typescript
TODOList of types
-
safe.u128unsigned type (tested) -
safe.u256unsigned type -
safe.i128signed type -
safe.i256signed type
-
fp128<Q>generic fixed point signed typeÙ (very basic for now) -
fp256<Q>generic fixed point signed typeÙ
-
safe.fp128<Q>generic fixed point signed typeÙ -
safe.fp256<Q>generic fixed point signed typeÙ
Ù typename Q is a type representing count of fractional bits

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
