Well, no more comments here. Just a hint: this piece of code is taken from a very enterprise UI and is supposed to round
val
with precision rdig
. I'm not really a Python evangelist or something but isn't there anything around that rounds numbers?fmt = "%%.0%df" % rdig # Do rounding m = 1.0 while rdig > 0: m *= 10.0 rdig -= 1 val = int(val * m + 0.5) / m val = fmt % val