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
🌐
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.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › toFixed
Number.prototype.toFixed() - JavaScript | MDN
js · (1000000000000000128).toString(); // '1000000000000000100' (1000000000000000128).toFixed(0); // '1000000000000000128' However, choosing a digits precision that's too high can return unexpected results, because decimal fractional numbers cannot be represented precisely in floating point.
🌐
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
🌐
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
Find elsewhere
🌐
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.
🌐
StackBlitz
stackblitz.com › edit › decimal-js
Decimal Js - StackBlitz
Blank starter project for building TypeScript apps.
🌐
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.
The light version of decimal.js, an arbitrary-precision Decimal type for JavaScript. - MikeMcl/decimal.js-light
Starred by 405 users
Forked by 49 users
Languages   JavaScript 99.8% | HTML 0.2%
🌐
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.
🌐
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.
🌐
W3Schools
w3schools.com › js › js_numbers.asp
W3Schools.com
JS Examples JS HTML DOM JS HTML Input JS HTML Objects JS HTML Events JS Browser JS Editor JS Exercises JS Quiz JS Website JS Syllabus JS Study Plan JS Interview Prep JS Bootcamp JS Certificate JS Reference ... JavaScript has only one type of number. Numbers can be written with or without decimals.
🌐
MojoAuth
mojoauth.com › binary-encoding-decoding › decimal-with-javascript-in-browser
Decimal with JavaScript in Browser | Binary Encoding Techniques Across Programming Languages
Handle decimal math accurately in browsers with JavaScript. Avoid floating-point errors for precise financial calculations and data.
🌐
GitHub
github.com › Agrora › decimal-js
GitHub - Agrora/decimal-js: DecimalJS is an arbitrary precision floating point arithmetic library based on PHP's bcmath extension.
import Decimal from '@agrora/decimal'; // Create a new decimal from a string const decimal = Decimal.from('0.2'); // Use add() to add another decimal to it const sum = decimal.add('0.1'); // Log the result as a string console.log(sum.toString()); ...
Author   Agrora