Rounding floats to specific amount of decimals (SOLVED)

I have no idea how to do this since the only rounding function is to integers.

I tried dividing my variable by 100 to 100000 to try to lose data on the last decimals, but it didn’t work.

Any ideas?

Is it possible to set the variable to a string and use the string slice function? It’s been a long while since I’ve launched OW but still pop on here to try to help

The problem is then you can’t use that stringyfied/truncated value for further calculations. If it is the goal to retirve such as final result etc. its fine to go, but thats it, you would need to back track and use the original value before truncating again for something else. Kinda of clunky and

Only the division by 100 would work any decimal digit at the position greater than 3 after the coma is cut out anyways if we want to representate decimal numbers with workshop like at debugging.

1 Like

It doesn’t work.

Edit:

For anyone wondering, I’ve found a mathematical solution to the problem. Here’s an example:

Let's say I want to round 1.4913 to a float with only 1 decimal accuracy.

1.4913 * 10 = 14.913

14.913 ≈ 15 (using the round to nearest integer function)

15 / 10 = 1.5

voila.
3 Likes

So, Divide(Round To Integer(Multiply(*number*, Raise To Power(10, *precision*))), Raise To Power(10, *precision*))

1 Like

Yes and the max of precision or number of digits to truncate is 3 for workshop.

3 Likes