I need to round up to 1 decimal place
If my number is 80.02 I need it to be 80.1.
tried
Math.ceil( (80.02).toFixed(1) ) but this rounds the number up to 81
How can I achieve this?
To round off decimal values using jQuery, we can use the built-in JavaScript methods toFixed() or toPrecision(). The toFixed() method converts a number into a string, keeping a specified number of decimals. The toPrecision() method formats a number to a specified length.
Definition and Usage. The Math. floor() method rounds a number DOWN to the nearest integer.
use Math.ceil( number * 10 ) / 10;
for rounding off
for fixing it to one decimal place
(Math.ceil( number * 10 ) / 10).toFixed(1);
Working Fiddle
I think it should work perfectly:
parseFloat(13.2*13.23).toFixed(1)
output:174.6
for your 80.02 - 80.0 and for 80.06-80.1 which is good
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With