[Solved] Is it possible to change the default rounding method in Python?
In one of the programming puzzle in codeabbey, it asks the numbers to be rounding in "Rounding half away from zero". In short, if the fractional part of x is exactly 0.5, then y = x + 0.5 if x is positive, and y = x − 0.5 if x is negative. Example 1: 123.5 becomes 124 Example 2: -123.5 becomes -124 https://en.wikipedia.org/wiki/Rounding#Rounding_half_away_from_zero Python round() method uses the "banker's rounding", which is not the behavior I want. To overcome the issue, I get the fractional part by f = abs(number - int(number)), and then use math module ceil / floor plus some conditional check to make the rounding. However, the site says it uses the same rounding algorithm in other puzzles unless explicitly specified. It would be a pain to re-implement the above method. Is there any setting we can change the default rounding behavior in Python? Or there is a built-in library can achieve the same result? The puzzle link: https://www.codeabbey.com/index/task_view/rounding