(Math.round(num * 100) / 100).toFixed(2);

Live Demo

var num1 = "1";
document.getElementById('num1').innerHTML = (Math.round(num1 * 100) / 100).toFixed(2);

var num2 = "1.341";
document.getElementById('num2').innerHTML = (Math.round(num2 * 100) / 100).toFixed(2);

var num3 = "1.345";
document.getElementById('num3').innerHTML = (Math.round(num3 * 100) / 100).toFixed(2);
span {
    border: 1px solid #000;
    margin: 5px;
    padding: 5px;
}
<span id="num1"></span>
<span id="num2"></span>
<span id="num3"></span>

Note that it will round to 2 decimal places, so the input 1.346 will return 1.35.

Answer from jrn.ak on Stack Overflow
๐ŸŒ
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 ยป
Discussions

Format with two decimal places
Overly complicated. Multiply by 100, round, then divide by 100. More on reddit.com
๐ŸŒ r/Notion
7
1
January 5, 2024
php - Show a number to two decimal places - Stack Overflow
Since round returns a float it ... of decimal places possible to represent the number). So round(1,2) (or any level or precision) returns '1.0', because '1.00' would not be a valid float. To make numbers behave like strings, you need to use string manipulation functions. (Previous versions of PHP may have acted differently/less logically) 2020-07-14T13:24:23.94Z+00:00 ... @fred2 - To convert float to a string with desired format, use sprintf ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to format numbers/text to 2 decimal places?
I need these numbers to be displayed at 2 decimal places. They currently go from 0 to MANY decimal places. I canโ€™t find a way to format numeric output to just 2 decimals. Feeling dumb - it could be Excel - or Grasshopper - or something in Notepadโ€ฆ TIA, Robb More on discourse.mcneel.com
๐ŸŒ discourse.mcneel.com
1
0
April 10, 2018
mysql - Format number to 2 decimal places - Stack Overflow
I would like to know how can I output a number with 2 decimal places, without rounding the original number. For example: 2229,999 -> 2229,99 I already tried: FORMAT(2229.999, 2) CONVERT(2229.... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Reddit
reddit.com โ€บ r/notion โ€บ format with two decimal places
r/Notion on Reddit: Format with two decimal places
January 5, 2024 -

Looks like managed to make a formula that formats my number with two decimal places, always. It uses two ifs, adding zeros when needed. The resulting output is a text, unfortunately.

if((prop("Estimated time, hrs")*10 - round(prop("Estimated time, hrs")*10) != 0), round(prop("Estimated time, hrs")*100)/100,if((prop("Estimated time, hrs")*10 - round(prop("Estimated time, hrs"))*10) != 0, join([format(prop("Estimated time, hrs")),"0"],""), join([format(prop("Estimated time, hrs")),"00"],".")))

๐ŸŒ
AskPython
askpython.com โ€บ home โ€บ how to format a number to 2 decimal places in python?
How to Format a Number to 2 Decimal Places in Python? - AskPython
February 27, 2023 - Also, using str.format() is simple, where you have to write within the curly braces how many places you want after the decimal followed by the variable name in the format function.
๐ŸŒ
Sololearn
sololearn.com โ€บ en โ€บ Discuss โ€บ 3288381 โ€บ how-to-round-to-2-decimal-places-in-python
How to round to 2 decimal places in python | Sololearn: Learn to code for FREE!
In your case, you can use round(number, 2) to round the number to 2 decimal places. Here's an example: number = 10.1234567 rounded_number = round(number, 2) print(rounded_number) # Output: 10.12 Alternatively, you can use the format() function ...
๐ŸŒ
Bobby Hadz
bobbyhadz.com โ€บ blog โ€บ javascript-format-number-to-two-decimal-places
Format a number to 2 Decimal places in JavaScript | bobbyhadz
Copied!const num1 = 13.505; const ... = parseFloat(str1).toFixed(2); console.log(result3); // ๐Ÿ‘‰๏ธ 13.10 ... The Number.toFixed() method formats a number to the specified number of decimal places....
Find elsewhere
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ python-round-to-two-decimal-places
How to Round to 2 Decimal Places in Python | DataCamp
August 8, 2024 - The f-strings were introduced in Python 3.6, and it offers a concise and efficient way to format strings and numbers. This method improves code readability and maintainability by embedding the expressions directly inside string literals. The code below prints 14.68. # Example number to be rounded number = 14.67856 # Using f-strings to round to 2 decimal places formatted_number = f"{number:.2f}" print(formatted_number) # 14.68
๐ŸŒ
Database Guide
database.guide โ€บ 4-functions-to-format-a-number-to-2-decimal-places-in-sql-server
4 Functions to Format a Number to 2 Decimal Places in SQL Server
February 9, 2022 - The same technique can be used to reduce the decimal places to two, from a number with more decimal places: ... Itโ€™s been rounded up, just like when we converted the number in the other example. Another way to do it is to use a custom format string. Custom format strings allow you to specify a format that might not be supported by a standard format string.
๐ŸŒ
SQL Server Guides
sqlserverguides.com โ€บ format-number-to-2-decimal-places-in-sql-server
Format Number to 2 Decimal Places in SQL Server - SQL Server Guides
November 9, 2023 - Now think you work with databases of ProductZone company in the USA and have to format the value within price columns to two decimal places for the product catalog. For that, use the below query. SELECT product_name, CAST(price AS decimal(10,2)) AS FormattedPrice FROM products; The output of the above query formatted the number within the price column with two decimal places as you can see in the above output.
๐ŸŒ
Mkyong
mkyong.com โ€บ home โ€บ java โ€บ java โ€“ display double in 2 decimal places
Java - Display double in 2 decimal places - Mkyong.com
October 29, 2021 - In Java, we can use DecimalFormat("0.00"), String.format("%.2f") or BigDecimal to display double in 2 decimal places.
๐ŸŒ
C# Examples
csharp-examples.net โ€บ string-format-double
String Format for Double [C#] - C# Examples
This example formats double to string with fixed number of decimal places. For two decimal places use pattern โ€ž0.00โ€œ. If a float number has less decimal places, the rest digits on the right will be zeroes. If it has more decimal places, the number will be rounded.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ How-to-format-a-number-with-two-decimals-in-JavaScript
How to format a number with two decimals in JavaScript?
October 31, 2023 - The Math.floor() method returns the greatest integer less than or equal to its argument. But we can use this method to format a number with two decimals.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ article โ€บ how-to-format-number-to-2-decimal-places-in-mysql
How to format number to 2 decimal places in MySQL?
March 19, 2023 - SELECT TRUNCATE(yourColumnName,2) as anyVariableName from yourTableName; To understand the above syntax, let us first create a table. The query to create a table is as follows ? mysql> create table FormatNumberTwoDecimalPlace -> ( -> Number float -> ); Query OK, 0 rows affected (0.59 sec) Insert some records in the table using insert command. The query is as follows ? mysql> insert into FormatNumberTwoDecimalPlace values(123.456); Query OK, 1 row affected (0.13 sec) mysql> insert into FormatNumberTwoDecimalPlace values(1.6789); Query OK, 1 row affected (0.19 sec) mysql> insert into FormatNumbe
๐ŸŒ
Microsoft Support
support.microsoft.com โ€บ en-us โ€บ office โ€บ round-a-number-to-the-decimal-places-i-want-in-excel-49b936f9-6904-425d-aa98-02ffb7f9a17b
Round a number to the decimal places I want in Excel - Microsoft Support
In the Places box, enter a positive number for digits to the right of the decimal point or a negative number for digits to the left of the decimal point. Note: For example, if you enter 3 in the Places box and then type 2834 in a cell, the value will be 2.834.
๐ŸŒ
SAS Support Communities
communities.sas.com โ€บ t5 โ€บ SAS-Procedures โ€บ changing-from-0-decimal-to-2-decimal-places โ€บ td-p โ€บ 203516
Solved: changing from 0 decimal to 2 decimal places - SAS Support Communities
June 11, 2015 - 9 5 0 2 0 0. - As you can see here there is not width available for the .00 ยท So you need to specify a format length which is you largest value (character length) + 1 for the decimal place + 2 for the additional 2 zeroes.