All Projects â†’ nefe â†’ Number Precision

nefe / Number Precision

🚀1K tiny & fast lib for doing addition, subtraction, multiplication and division operations precisely

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Number Precision

FpDebug
Dynamic Program Analysis based on Valgrind to find Floating-Point Accuracy Problems
Stars: ✭ 19 (-99.43%)
Mutual labels:  floating-point
decimal
An arbitrary-precision decimal floating-point arithmetic package for Go
Stars: ✭ 28 (-99.16%)
Mutual labels:  floating-point
number-format
Wrapper above number_format and unit convertor.
Stars: ✭ 18 (-99.46%)
Mutual labels:  number-converter
shellmath
Yes, Virginia, you can do floating-point arithmetic in Bash!
Stars: ✭ 33 (-99.01%)
Mutual labels:  floating-point
float eq-rs
Compare IEEE floating point values for equality.
Stars: ✭ 34 (-98.98%)
Mutual labels:  floating-point
verificarlo
A tool for debugging and assessing floating point precision and reproducibility.
Stars: ✭ 51 (-98.48%)
Mutual labels:  floating-point
DecFP.jl
Julia IEEE decimal floating-point via the Intel decimal-float library
Stars: ✭ 49 (-98.54%)
Mutual labels:  floating-point
number-to-words
convert number into words (english, french, italian, roman, spanish, portuguese, belgium, dutch, swedish, polish, russian, iranian, roman, aegean)
Stars: ✭ 53 (-98.42%)
Mutual labels:  number-converter
fpzip
Cython bindings for fpzip, a floating point image compression algorithm.
Stars: ✭ 24 (-99.28%)
Mutual labels:  floating-point
fphdl
VHDL-2008 Support Library
Stars: ✭ 36 (-98.92%)
Mutual labels:  floating-point
floaxie
Floating point printing and parsing library based on Grisu2 and Krosh algorithms
Stars: ✭ 28 (-99.16%)
Mutual labels:  floating-point
FPChecker
A dynamic analysis tool to detect floating-point errors in HPC applications.
Stars: ✭ 26 (-99.22%)
Mutual labels:  floating-point
Drachennest
Different algorithms for converting binary to decimal floating-point numbers
Stars: ✭ 60 (-98.21%)
Mutual labels:  floating-point
herbie
Optimize floating-point expressions for accuracy
Stars: ✭ 614 (-81.64%)
Mutual labels:  floating-point
DoubleFloats.jl
math with more good bits
Stars: ✭ 102 (-96.95%)
Mutual labels:  floating-point
python-baseconv
Python module to convert numbers from base 10 integers to base X strings and back again.
Stars: ✭ 40 (-98.8%)
Mutual labels:  number-converter
Guide-to-Swift-Numbers-Sample-Code
Xcode Playground Sample Code for the Flight School Guide to Swift Numbers
Stars: ✭ 92 (-97.25%)
Mutual labels:  floating-point
fpzip
Lossless compressor of multidimensional floating-point arrays
Stars: ✭ 58 (-98.27%)
Mutual labels:  floating-point
ChangePrecision.jl
macro to change the default floating-point precision in Julia code
Stars: ✭ 28 (-99.16%)
Mutual labels:  floating-point
ndzip
A High-Throughput Parallel Lossless Compressor for Scientific Data
Stars: ✭ 19 (-99.43%)
Mutual labels:  floating-point

number-precision npm version Build Status codecov

Perform addition, subtraction, multiplication and division operations precisely using javascript

Why

0.1 + 0.2 = 0.30000000000000004
1.0 - 0.9 = 0.09999999999999998
0.105.toFixed(2) = 0.1 // not 0.11

Install

npm install number-precision --save

Methods

NP.strip(num)         // strip a number to nearest right number
NP.plus(num1, num2, num3, ...)   // addition, num + num2 + num3, two numbers is required at least.
NP.minus(num1, num2, num3, ...)  // subtraction, num1 - num2 - num3
NP.times(num1, num2, num3, ...)  // multiplication, num1 * num2 * num3
NP.divide(num1, num2, num3, ...) // division, num1 / num2 / num3
NP.round(num, ratio)  // round a number based on ratio

Usage

import NP from 'number-precision'
NP.strip(0.09999999999999998); // = 0.1
NP.plus(0.1, 0.2);             // = 0.3, not 0.30000000000000004
NP.plus(2.3, 2.4);             // = 4.7, not 4.699999999999999
NP.minus(1.0, 0.9);            // = 0.1, not 0.09999999999999998
NP.times(3, 0.3);              // = 0.9, not 0.8999999999999999
NP.times(0.362, 100);          // = 36.2, not 36.199999999999996
NP.divide(1.21, 1.1);          // = 1.1, not 1.0999999999999999
NP.round(0.105, 2);            // = 0.11, not 0.1

PS: If you want to get rid of XXX is beyond boundary when transfer to integer, the results may not be accurate, use this at the beginning of your app to turn off boundary checking.

NP.enableBoundaryChecking(false); // default param is true

License

MIT

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].