def rounded(num, precision=0):
 precision = cint(precision)
 multiplier = (10 ** precision)
 num = round(((num * multiplier) if precision else num), 8)
 floor = math.floor(num)
 decimal_part = (num - floor)
 if ((not precision) and (decimal_part == 0.5)):
  num = (floor if ((floor % 2) == 0) else (floor + 1))
 else:
  num = round(num)
 return ((num / multiplier) if precision else num)

def rounded ( num , precision = 0 ) : precision = cint ( precision ) multiplier = ( 10 ** precision ) num = round ( ( ( num * multiplier ) if precision else num ) , 8 ) floor = math . floor ( num ) decimal_part = ( num - floor ) if ( ( not precision ) and ( decimal_part == 0.5 ) ) : num = ( floor if ( ( floor % 2 ) == 0 ) else ( floor + 1 ) ) else : num = round ( num ) return ( ( num / multiplier ) if precision else num )
round method for round halfs to nearest even algorithm aka bankers rounding - compatible with python3 .