Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cutting excessive trails off a float

I am getting numbers back from postgre db in float format and when trying to print them in my html page they took too much space. How do I cut the excessive precision number using a quick JS function? i.e:

98.7776 --> 98.7
like image 965
Max Avatar asked Dec 07 '25 08:12

Max


1 Answers

var num = 98.7776;
var result = num.toFixed(1);
like image 139
Thilo Savage Avatar answered Dec 08 '25 23:12

Thilo Savage



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!