Convert the number into a string, match the number up to the second decimal place:

function calc(theform) {
    var num = theform.original.value, rounded = theform.rounded
    var with2Decimals = num.toString().match(/^-?\d+(?:\.\d{0,2})?/)[0]
    rounded.value = with2Decimals
}
<form onsubmit="return calc(this)">
Original number: <input name="original" type="text" onkeyup="calc(form)" onchange="calc(form)" />
<br />"Rounded" number: <input name="rounded" type="text" placeholder="readonly" readonly>
</form>

The toFixed method fails in some cases unlike toString, so be very careful with it.

Answer from Gumbo on Stack Overflow
🌐
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...
🌐
Adobe Acrobat
acrobatusers.com › forum › javascript › rounding-2-decimal-places-without-rounding
Rounding to 2 decimal places without rounding up
Have you looked at the "parseInt" object or the 'Math.floor' method // document level script using parseInt to truncate to nDec places function Int(nValue, nDec) { // parseInt nValue to nDec places var nAdj = Math.pow(10, parseInt(nDec)) return parseInt(nValue * nAdj) / nAdj; } // document level script using Math.floor to truncate to nDec places function Floor(nValue, nDec) { // truncate a value at nDec places var nAdj = Math.pow(10, Math.floor(nDec)) return Math.floor(nValue * nAdj) / nAdj; } // custom calculation script to truncate computation to nDec places var m1 = this.getField("miles1");
🌐
QuickRef.ME
quickref.me › home › how to truncate a number to a given number of decimal places without rounding in javascript - quickref.me
How to truncate a number to a given number of decimal places without rounding in JavaScript - QuickRef.ME
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function. Let's define this short function: const toFixed = (n, fixed) => `${n}`.match(new RegExp(`^-?\\d+(?:\.\\d{0,${fixed}})?`))[0]; const ...
🌐
OutSystems
outsystems.com › forums › discussion › 90504 › decimal-with-2-digits-without-round-off
Decimal with 2 digits without round off | OutSystems
I need decimal value with 2 decimal places for the amount and it should not be rounded instead it should be cut off to 2 decimal places · Example: 4816.875 should display as 4816.87 or 3699.095 should display as 3699.09
🌐
ThisCodeWorks
thiscodeworks.com › javascript-truncate-number-to-two-decimal-places-without-rounding-stack-overflow › 619e399485dcaf00159171e9
javascript - Truncate number to two decimal places without rounding - Stack Overflow | thiscodeWorks
num = num.toString(); //If it's not already a String num = num.slice(0, (num.indexOf("."))+3); //With 3 exposing the hundredths place Number(num); //If you need it back as a Number content_copyCOPY https://stackoverflow.com/questions/4187146/truncate-number-to-two-decimal-places-without-rounding
🌐
W3Schools
w3schools.com › jsref › jsref_tofixed.asp
JavaScript toFixed() Method
❮ Previous JavaScript Number Reference Next ❯ · let num = 5.56789; let n = num.toFixed(); Try it Yourself » · let num = 5.56789; let n = num.toFixed(2); Try it Yourself » · More examples below · The toFixed() method converts a number ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-parse-float-with-two-decimal-places-in-javascript
How to Parse Float with Two Decimal Places in JavaScript? - GeeksforGeeks
This method ensures no rounding, preserving exact precision. Example: In this example, the ParseFloat converts a string to a number with specified decimal places. It slices the string up to the desired decimal precision and then converts it back to a number. ... function ParseFloat(str,val) { str = str.toString(); str = str.slice(0, (str.indexOf(".")) + val + 1); return Number(str); } console.log(ParseFloat("10.547892",2)) ... JavaScript is best known for web page development but it is also used in a variety of non-browser environments.
Published   July 23, 2025
Find elsewhere
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Numbers
Removes anything after the decimal point without rounding: 3.1 becomes 3, -1.1 becomes -1. Here’s the table to summarize the differences between them: These functions cover all of the possible ways to deal with the decimal part of a number. But what if we’d like to round the number to n-th digit after the decimal? For instance, we have 1.2345 and want to round it to 2 digits, getting only 1.23.
🌐
w3tutorials
w3tutorials.net › blog › truncate-number-to-two-decimal-places-without-rounding
How to Truncate a Number to Two Decimal Places Without Rounding in JavaScript: Avoiding toFixed Rounding Issues — w3tutorials.net
How it works: The epsilon (0.00000001) ensures numbers like 28.999999999999996 round up to 29.000000009999996, which Math.trunc() correctly truncates to 29. Convert the number to a string, split it at the decimal point, and manually truncate the fractional part. This avoids floating-point errors entirely. ... Convert the number to a string. Split into integer and fractional parts using split('.'). Truncate the fractional part to 2 digits (pad with zeros if too short).
🌐
Experts Exchange
experts-exchange.com › questions › 29101720 › Delete-digits-after-two-decimal-points-without-rounding-the-value-in-javascript-jquery.html
Solved: Delete digits after two decimal points, without rounding the value in javascript/jquery | Experts Exchange
April 6, 2018 - Delete digits after two decimal points, without rounding the value in javascript/jquery var a=987.687 but i need the value like 987.68 how to get value like that ... We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads. ... a = a.toFixed(2); // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed
🌐
javaspring
javaspring.net › blog › limit-the-amount-of-number-shown-after-a-decimal-place-in-javascript
How to Limit Decimal Places to Two Digits in JavaScript Without Rounding — javaspring.net
Displaying raw measurements where rounding could misrepresent accuracy. The Math.trunc() function in JavaScript removes the decimal part of a number, returning the integer portion.
🌐
Codedamn
codedamn.com › news › javascript
JavaScript round a number to 2 decimal places (with examples)
December 11, 2022 - These are functions defined by the users themselves. here I have shown some examples below: Example of a user-defined function by using an exponent. It will round the number up and down. “e+2”, 2 is for 2 decimal places.
🌐
W3Schools
w3schools.com › howto › howto_js_format_number_dec.asp
How To Format a Number with Two Decimals
You can use the toFixed() method to format a number to only show two decimals. Note that the result is rounded (shows 5.57 instead of 5.56): let num = 5.56789; let n = num.toFixed(2); // 5.57 Try it Yourself »
🌐
CoreUI
coreui.io › blog › how-to-round-a-number-to-two-decimal-places-in-javascript
How to round a number to two decimal places in JavaScript · CoreUI
February 21, 2024 - The key to rounding to 2 decimal places is to manipulate the number such that the function applies rounding at the correct decimal position, as illustrated through the methods above. How do you round numbers in JavaScript without built-in methods?