Skip to content

Latest commit

 

History

History
48 lines (30 loc) · 1.13 KB

quick-start.md

File metadata and controls

48 lines (30 loc) · 1.13 KB

Quick Start

Requirements

  • npm or Yarn
  • Node.js 12+

Installation

npm install @trezy/bigmath

# OR

yarn add @trezy/bigmath

Usage

@trezy/bigmath has two main exports: BigFloat and BigMath. BigFloat is useful for storing arbitrary precision values that you'll need to use later:

import { BigFloat } from '@trezy/bigmath'

const foo = new BigFloat('9007199254740991.1')

// Do some other stuff.

const newValue = foo.add('100.000000000000000001')

For more details about using BigMath, checkout the BigMath documentation.

BigMath, on the other hand, is useful for performing complex calculations against a number of arbitrary input types, including BigInts, numbers, floats, numbers–as–strings, and even other BigFloats. The output of BigMath operations will always be a BigFloat.

import {
  BigFloat,
  BigMath,
} from '@trezy/bigmath'

const foo = BigMath.add(2, 2)

foo.toString() // Outputs '4.000000000000000000'
typeof foo === BigFloat // true

For more details about using BigFloat, checkout the BigFloat documentation.