0.0.4 • Published 11 months ago

@awsless/big-float v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

npm version npm version license

A library for arbitrary precision decimal floating point arithmetic that can exactly represent all decimal fractions, unlike JavaScript's number data type which is 64-bit binary floating point.

We are wrapping bigfloat-esnext behind the scenes.

Basic usage

import { BigFloat, sqrt } from "@awsless/big-float";

sqrt(new BigFloat(2)).toString()      // "1.4142"

Change precision

import { sqrt, set_precision } from "@awsless/big-float";

sqrt(2).toString();     // "1.4142"
set_precision(-10);
sqrt(2).toString();     // "1.4142135623"

The bigfloat interface

interface IBigFloat {
  coefficient: bigint;
  exponent: number;
}

Available API

import { BigFloat, set_precision } from "@awsless/big-float";

// arithmetic
import { neg, abs, add, sub, mul, div, sqrt, pow, ceil, floor, factor } from '@awsless/big-float'

// retational
export { eq, lt, lte, gt, gte, min, max } from '@awsless/big-float'

// constants
export { ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, HUNDRED, THOUSAND, MILLION, BILLION, TRILLION } from '@awsless/big-float'
0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

12 months ago

0.0.1

1 year ago