Expand my Community achievements bar.

SOLVED

Rounding with decimals

Avatar

Level 6

I can't find a way to round a number to a specific number of decimals. So e.g. 3.14159 to 3.1416 or 3.14

I'm surely missing something. Any ideas where to find that function?

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi Chris,

We use round, but have to extend the number past the decimal range first because our round() feature only rounds to the nearest integer.

Using this method on 3.14159 i get

0694X00000HEKn3QAH.pngThe formulas to handle this look like this:

0694X00000HEKoLQAX.pngSo, again , you round the number multiplied by the factor of the digits you want then divide the newly rounded integer by the same factor

View solution in original post

4 Replies

Avatar

Level 4

formatNumber under math functions. ~Jeff

Avatar

Level 6

Hi @Jeff Rieth‚ thanks for the answer. I tried that but it just cuts off at the defined decimal number, it doesn't round :-(

Avatar

Correct answer by
Employee

Hi Chris,

We use round, but have to extend the number past the decimal range first because our round() feature only rounds to the nearest integer.

Using this method on 3.14159 i get

0694X00000HEKn3QAH.pngThe formulas to handle this look like this:

0694X00000HEKoLQAX.pngSo, again , you round the number multiplied by the factor of the digits you want then divide the newly rounded integer by the same factor

Avatar

Level 6

@Andy Hess‚ thanks for the solution! Perhaps it makes sense that this finds its way into the documentation?