Set number of decimal places with postf or others


I want to format the output of a bunch of incoming numbers, and limit the amount of decimal places, so that:

postf("x: %", x)

where x is f.x. 0.3456927324214 will produce 0.34, something along the line of how printf works in c:

printf("%.2f", 2.333333333) -> 2.33

So far I haven’t found any method in the documentation that would allow this… I’m hoping I’m wrong.


OK, figured it out, I had to solve it on the input side, not the formatting side:

postf("x: %", x.trunc(0.01))

works as expected.