Skip to content

quentinadam/deno-decimal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@quentinadam/decimal

JSR NPM CI

A library for working with arbitrary precision decimal numbers.

Decimal numbers are represented by a mantissa (bigint) and an exponent (number). Instances of the Decimal class are immutable; calling functions (like abs, add, ceil, ...) on an instance will return a new Decimal instance with the result. Division may fail if the resulting number cannot be represented with a fixed number of decimals (like 1/3). Please check the documentation of the div function for more details.

Usage

import { Decimal } from '@quentinadam/decimal';
import { assert } from '@quentinadam/assert';

const a = Decimal.from('1.11111111111111111111');

const b = a.mul(2);

assert(b.toString() === '2.22222222222222222222');

const c = a.add(b);

assert(c.toString() === '3.33333333333333333333');

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors