Decimal128
JavaScript userland partial implementation of IEEE 754 Decimal128 decimal floating-point arithmetic
Install / Use
/learn @jessealama/Decimal128README
decimal128.js—A userland approximation to IEEE 754 Decimal128 in JavaScript
This repository has been archived. Development has moved to proposal-decimal-polyfill.
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
- absolute value (
abs) - addition (
add) - subtraction (
subtract) - multiplication (
multiply) - division (
divide) - remainder (
remainder) - rounding (
round) toStringemitting both decimal and exponential syntax (default is decimal)
Comparisons
- equality (
equals) to compare for mathematical equality - less than (
lessThan) to compare mathematical order comparefor comparing Decimals as digit strings (not mathematical order; e.g.1.2<1.20)
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!
Related Skills
node-connect
345.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
106.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
