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

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

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

3 Likes

Oh nice. that works.

Thanks @bojanvelevski

Manohar