Forum Discussion

manohar's avatar
manohar
Contributor
5 years ago

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

2 Replies

  • bojanvelevski's avatar
    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 :

    I hope this helps,
    Regards
    Bojan