All Projects → MikeMcl → Decimal.js Light

MikeMcl / Decimal.js Light

Licence: mit
The light version of decimal.js, an arbitrary-precision Decimal type for JavaScript.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Decimal.js Light

wide-integer
Wide-Integer implements a generic C++ template for uint128_t, uint256_t, uint512_t, uint1024_t, etc.
Stars: ✭ 83 (-64.98%)
Mutual labels:  arbitrary-precision
Rpn
Math functional language, inspired by Hewlett-Packard Reverse Polish Notation (RPL) language
Stars: ✭ 17 (-92.83%)
Mutual labels:  arbitrary-precision
Calc
C-style arbitrary precision calculator
Stars: ✭ 127 (-46.41%)
Mutual labels:  arbitrary-precision
Arb
C library for arbitrary-precision ball arithmetic
Stars: ✭ 280 (+18.14%)
Mutual labels:  arbitrary-precision
Bignumber.js
A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic
Stars: ✭ 5,174 (+2083.12%)
Mutual labels:  arbitrary-precision
Math
Arbitrary-precision arithmetic library for PHP
Stars: ✭ 905 (+281.86%)
Mutual labels:  arbitrary-precision
decimal
An object-oriented implementation of basic math operation with arbitrary precision, using BC Math if available.
Stars: ✭ 14 (-94.09%)
Mutual labels:  arbitrary-precision
Javascript Biginteger
A big integer library for JavaScript
Stars: ✭ 181 (-23.63%)
Mutual labels:  arbitrary-precision
Mpmath
Python library for arbitrary-precision floating-point arithmetic
Stars: ✭ 511 (+115.61%)
Mutual labels:  arbitrary-precision
Kotlin Multiplatform Bignum
A Kotlin multiplatform library for arbitrary precision arithmetics
Stars: ✭ 119 (-49.79%)
Mutual labels:  arbitrary-precision
Big.js
A small, fast JavaScript library for arbitrary-precision decimal arithmetic.
Stars: ✭ 3,730 (+1473.84%)
Mutual labels:  arbitrary-precision
Decimal.js
An arbitrary-precision Decimal type for JavaScript
Stars: ✭ 4,585 (+1834.6%)
Mutual labels:  arbitrary-precision
Rationals
🔟 Implementation of rational number arithmetic for .NET with arbitrary precision.
Stars: ✭ 40 (-83.12%)
Mutual labels:  arbitrary-precision
Angourimath
Open-source symbolic algebra library for C# and F#. One of the most powerful in .NET
Stars: ✭ 266 (+12.24%)
Mutual labels:  arbitrary-precision
Swift Bigint
A lightweight, Multiple Precision Arithmetic Library for Swift!
Stars: ✭ 144 (-39.24%)
Mutual labels:  arbitrary-precision
imath
Arbitrary precision integer and rational arithmetic library
Stars: ✭ 92 (-61.18%)
Mutual labels:  arbitrary-precision
Lua Bint
Arbitrary precision integer arithmetic library in pure Lua
Stars: ✭ 20 (-91.56%)
Mutual labels:  arbitrary-precision
Tiny Bignum C
Small portable multiple-precision unsigned integer arithmetic in C
Stars: ✭ 224 (-5.49%)
Mutual labels:  arbitrary-precision
Big Math
Advanced Java BigDecimal math functions (pow, sqrt, log, sin, ...) using arbitrary precision.
Stars: ✭ 173 (-27%)
Mutual labels:  arbitrary-precision
Physicalconstants.jl
Collection of fundamental physical constants with uncertainties. It supports arbitrary-precision constants
Stars: ✭ 55 (-76.79%)
Mutual labels:  arbitrary-precision

decimal.js-light

The light version of decimal.js, an arbitrary-precision Decimal type for JavaScript.

Build Status


This library is the newest of the family of libraries: bignumber.js, big.js, decimal.js and decimal.js-light.
The API is more or less a subset of the API of decimal.js.

API

Differences between this library and decimal.js

Size of decimal.js minified: 32.1 KB.
Size of decimal.js-light minified: 12.7 KB.

This library does not include NaN, Infinity or -0 as legitimate values, or work with values in other bases.

Here, the Decimal.round property is just the default rounding mode for toDecimalPlaces, toExponential, toFixed, toPrecision and toSignificantDigits. It does not apply to arithmetic operations, which are simply truncated at the required precision.

If rounding is required just apply it explicitly, for example

x = new Decimal(2);
y = new Decimal(3);

// decimal.js
x.dividedBy(y).toString();                       // '0.66666666666666666667'

// decimal.js-light
x.dividedBy(y).toString();                       // '0.66666666666666666666'
x.dividedBy(y).toDecimalPlaces(19).toString();   // '0.6666666666666666667'

The naturalExponential, naturalLogarithm, logarithm, and toPower methods in this library have by default a limited precision of around 100 digits. This limit can be increased at runtime using the LN10 (the natural logarithm of ten) configuration object property.

For example, if a maximum precision of 400 digits is required for these operations use

// 415 digits
Decimal.set({
  LN10: '2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286248633409525465082806756666287369098781689482907208325554680843799894826233198528393505308965377732628846163366222287698219886746543667474404243274365155048934314939391479619404400222105101714174800368808401264708068556774321622835522011480466371565912137345074785694768346361679210180644507064800027'
});

Also, in this library the e property of a Decimal is the base 10000000 exponent, not the base 10 exponent as in decimal.js.
Use the exponent method to get the base 10 exponent.

Quickstart

Browser:

<script src='path/to/decimal.js-light'></script>

Node package manager:

$ npm install --save decimal.js-light
// Node.js
var Decimal = require('decimal.js-light');

// Adjust the global configuration if required (these are the defaults)
Decimal.set({
  precision: 20,
  rounding: Decimal.ROUND_HALF_UP,
  toExpNeg: -7,
  toExpPos: 21
});

phi = new Decimal('1.61803398874989484820458683436563811772030917980576');

phi.toFixed(10);    // '1.6180339887'

phi.times(2).minus(1).toPower(2).plus('1e-19').equals(5);    // true

See the documentation for further information.

TypeScript type declaration file contributed by TANAKA Koichi.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].