I'm using this function to round up floating 5s in Python:
def round_half_up_xx(n, decimals=2):
multiplier = 10 ** decimals
return math.floor(n*multiplier + 0.5) / multiplier
I'm getting weird results:
- round_half_up_xx(81.225) => 81.22
- round_half_up_xx(81.235) => 81.24
How do I revise the code so that round_half_up_xx(81.225) yields 81.23?