Rounding decimal problem

I want to round/cut a number to two digits before and after the dot. xx.xx

So i use trunc(25.31879431 * 100) / 100
and get 25.31

When I have 5.31879431 I add the first zero at the text output.

But when I have 25.30879431 I get a problem, 25.3 the last zero is missing.

Any idea?

Same thing, add a 0 at the end of the text output. :man_shrugging:

If which condition is true?:ok_man:

trunc output length isn’t the expected length?:no_good_man:

I think the easiest way would be not to divide and cut the string to add the dot.

Number formatting is not something trivial. Apparently, you’re not alone:

Is it panned to add formatting functions?

So it works for me so far.

1 Like