cancel
Showing results for 
Search instead for 
Did you mean: 

To remove trailing zeros after decimal or adding trailing zeroes for camparison

manohar
Contributor

hi there,

I need to compare 2 values, example as below. either adding zeroes or removing zeroes.

44.5500
44.55

how can I achieve this?

Thanks
Manohar

2 REPLIES 2

bojanvelevski
Valued Contributor

Hi @manohar,

You can use the “.toPrecision()” method, where you can add an argument on how may digits you want in your number. Example:

parseFloat(44.55).toPrecision(6) gives you :

image

I hope this helps,
Regards
Bojan

Oh nice. that works.

Thanks @bojanvelevski

Manohar