Is there an function in python 2 that can do this?
1234 -> round(1234, 2) = 1200
1234 -> round(1234, 3) = 1230
12.34 -> round(12.34, 3) = 12.3
Basically the second number says the precision of the number and the everything behind should be rounded.
Based on the comment i came up with this:
def round_to_precision(x, precision):
return int(round(x / float(10 ** precision))) * 10 ** precision
But this is still wrong, because i don't know the size of the numbers.