jessealama / decimal128

JavaScript userland partial implementation of IEEE 754 Decimal128 decimal floating-point arithmetic
BSD 2-Clause "Simplified" License
19 stars 8 forks source link

decimal128.js—A userland approximation to IEEE 754 Decimal128 in JavaScript

This library is a prototype for the decimal proposal. There should be no observable difference between what this library does and what the proposal is supposed to do. If you find a mismatch, please file an issue in this repo.

Operations

Comparisons

Implementation

This package is written in TypeScript. Unit tests are in Jest. There are no other external dependencies.

Data model

This package aims to reproduce the IEEE 754 Decimal128 128-bit decimal floating-point numbers in JavaScript. See the decimal proposal. These decimal (not binary!) numbers take up 128 bits per number. This format allows for an exact representation of decimal numbers with 34 (decimal) significant digits and an exponent between -6143 and 6144. That's a vast amount of range and precision!