8.833333333339 (or 8.833333333333334 , result 106.00/12 ), correctly rounded to two decimal places, is 8.83 . Mathematically, it looks like you want a ceiling function . The one in the Python math module is called ceil :
import math v = 8.8333333333333339 print(math.ceil(v*100)/100)
Accordingly, the floor and ceiling functions usually map a real number to the largest previous or smallest next integer that has zero decimal places - therefore, to use them for two decimal places, the number is first multiplied by 10 2 (or 100) to shift decimal point and then divide by it to compensate.
If for some reason you do not want to use the math module, you can use this (minimally tested) implementation that I just wrote:
def ceiling(x): n = int(x) return n if n-1 < x <= n else n+1

An example of the conclusion shows that they rounded the monthly payment, which many call the effect of the ceiling function. This means that a little more than 1 & frasl; 12 of the total amount. This made the final payment a little less than usual - leaving the remaining unpaid balance of only 8.76 .
It would be fair to use regular rounding, creating a monthly payment of 8.83 and a slightly higher final payment of 8.87 . However, in the real world, people usually donβt like when their payments grow, so rounding off each payment is a common practice - it also returns money to the lender faster.
martineau Dec 23 '10 at 13:13 2010-12-23 13:13
source share