Both of these work except sometimes a decimal of 5 is rounded down instead of up. Drop the decimal places without rounding off Mathtrunc 345. Using Mathround method to round off the number to 2 decimal places in javascript.
In Java there are a few ways to round float or double to 2 decimal places.
To get the result with two decimals you can do like this. In JavaScript code that is simple to achieve. To round off any number to any decimal place we can use this method by first multiplying the input number with 10 decimal place so in our case it is 2 that is Mathround314159265359 10 2 and then divide it by 10 decimal place like Mathround314159265359. The round method.