cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Can we round integers to 2 digits?

darshthakkar
Valued Contributor

Hi Team,

I was using the Math.round() but was wondering if we can decide on the decimal digits for the rounding.

For example, number = 3.14125252
Desired output = 3.14

With Math.round(), output is 3.

Any suggestions on how to use the native Round(number,2) format?
Thank you.

Regards,
Darsh

1 ACCEPTED SOLUTION

Abhishek_Soni37
Contributor

Hey @darshthakkar ,

Try this function toFixed.

Input:
image

Expression:
image

Result:
image

View solution in original post

2 REPLIES 2

Abhishek_Soni37
Contributor

Hey @darshthakkar ,

Try this function toFixed.

Input:
image

Expression:
image

Result:
image

darshthakkar
Valued Contributor

Thank you @Soni37 for the insights.
I had to convert my string to a number and then apply this formula. I was also able to learn more about .toPrecision()

Link to the documentation

Thank you again.