JavaScript: You can convert to number to floating number with two decimal point.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | <!doctype html> <html> <head> <meta charset="utf-8"> <title>javascript round to 2 decimal</title> </head> <body> <script> var number=12.4528; number=number.toFixed(2); console.log(number); //type string number=Number(number); console.log(number); //type number //final number=Number(number.toFixed(2)); console.log(number); </script> </body> </html> |
Output: