Use 1, not 2.

js> 2.3 % 1
0.2999999999999998
Answer from Ignacio Vazquez-Abrams on Stack Overflow
🌐
Mikemcl
mikemcl.github.io › decimal.js
decimal.js API
To make the crypto object available globally in Node.js use ... If the value of this Decimal constructor's crypto property is set true and the crypto object and associated method are not available, an exception will be thrown.
🌐
GitHub
github.com › MikeMcl › decimal.js
GitHub - MikeMcl/decimal.js: An arbitrary-precision Decimal type for JavaScript · GitHub
An arbitrary-precision Decimal type for JavaScript. ... The library is similar to bignumber.js, but here precision is specified in terms of significant digits rather than decimal places, and all calculations are rounded to the precision (similar ...
Author   MikeMcl
🌐
npm
npmjs.com › package › decimal.js
decimal.js - npm
An arbitrary-precision Decimal type for JavaScript. ... The library is similar to bignumber.js, but here precision is specified in terms of significant digits rather than decimal places, and all calculations are rounded to the precision (similar ...
      » npm install decimal.js
    
Published   Jul 06, 2025
Version   10.6.0
Author   Michael Mclaughlin
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › toFixed
Number.prototype.toFixed() - JavaScript | MDN
The toFixed() method of Number values returns a string representing this number using fixed-point notation with the specified number of decimal places. function financial(x) { return Number.parseFloat(x).toFixed(2); } console.log(financial(123.456)); // Expected output: "123.46" console.lo...
🌐
W3Schools
w3schools.com › jsref › jsref_tofixed.asp
W3Schools.com
cssText getPropertyPriority() ... · The toFixed() method converts a number to a string. The toFixed() method rounds the string to a specified number of decimals....
🌐
JSFiddle
jsfiddle.net › NathanFriend › r68puwyw
Decimal.js and JSON.stringify() - JSFiddle - Code Playground
The Code Completion will now also have the context of all panels before suggesting code to you - so if for example you have some CSS or JS, the HTML panel will suggest code based on the other two panels.
Find elsewhere
🌐
GitHub
github.com › tc39 › proposal-decimal
GitHub - tc39/proposal-decimal: Built-in exact decimal numbers for JavaScript · GitHub
Built-in exact decimal numbers for JavaScript. Contribute to tc39/proposal-decimal development by creating an account on GitHub.
Author   tc39
🌐
StackBlitz
stackblitz.com › edit › decimal-js
Decimal Js - StackBlitz
Blank starter project for building TypeScript apps.
🌐
Progress
progress.com › blogs › decimals-no-limitations-javascript
Decimals with No Limitations in JavaScript
November 13, 2024 - Here is one last example to show rounding with large numbers: Decimal 1,234,567,890,123 multiplied by Decimal 1 will yield 123460000000. Here, rounding takes place at the 5th digit. There are multiple ways to round numbers. Check the last section on the configuration options for the rounding mode. Corticon.js is used to implement low-code/no-code decision services.
🌐
GitHub
github.com › MikeMcl › decimal.js-light
GitHub - MikeMcl/decimal.js-light: The light version of decimal.js, an arbitrary-precision Decimal type for JavaScript. · GitHub
The light version of decimal.js, an arbitrary-precision Decimal type for JavaScript. - MikeMcl/decimal.js-light
Author   MikeMcl
🌐
GitHub
github.com › MikeMcl › decimal.js › blob › master › decimal.mjs
decimal.js/decimal.mjs at master · MikeMcl/decimal.js
// See https://github.com/MikeMcl/decimal.js/pull/217 · x = new Ctor(1).minus(x).div(x.plus(1)).sqrt().atan(); · Ctor.precision = pr; Ctor.rounding = rm; · return x.times(2); }; · · /* * Return a new Decimal whose value is the inverse of the hyperbolic cosine in radians of the ·
Author   MikeMcl
🌐
Decimali
decimali.sh
Decimalish — arbitrary-precision decimal primitives for JavaScript.
Decimalish can be used anywhere you use JavaScript. It supports decades-old browsers, modern module-aware Node.js, and web compilers like Webpack.
🌐
cdnjs
cdnjs.com › home › libraries › decimal.js › 9.0.0
decimal.js - Libraries - cdnjs - The #1 free and open source CDN built to make life easier for developers
Content delivery at its finest. cdnjs is a free and open-source CDN service trusted by over 12.5% of all websites, serving over 200 billion requests each month, powered by Cloudflare.
🌐
Adripofjavascript
adripofjavascript.com › blog › drips › avoiding-problems-with-decimal-math-in-javascript.html
Avoiding Problems with Decimal Math in JavaScript - A Drip of JavaScript
Division of integers and multiplication by decimals may still result in inexact values, but basic integer addition, subtraction, and multiplication will be accurate. (At least until you hit JavaScript's upper limit for numbers.) Thanks for reading! ... Want to improve your JavaScript skills? Subscribe to A Drip of JavaScript for biweekly tips to help you level up as a JS ...