jack
1
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?
Gruk
2
Same thing, add a 0 at the end of the text output. ![:man_shrugging: :man_shrugging:](https://forum.gdevelop.io/images/emoji/apple/man_shrugging.png?v=12)
jack
3
If which condition is true?![:ok_man: :ok_man:](https://forum.gdevelop.io/images/emoji/apple/ok_man.png?v=12)
Gruk
4
trunc output length isn’t the expected length?![:no_good_man: :no_good_man:](https://forum.gdevelop.io/images/emoji/apple/no_good_man.png?v=12)
davy
5
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?
jack
6
So it works for me so far.
1 Like