def float_round(value, precision_digits=None, precision_rounding=None, rounding_method='HALF-UP'):
 rounding_factor = _float_check_precision(precision_digits=precision_digits, precision_rounding=precision_rounding)
 if ((rounding_factor == 0) or (value == 0)):
  return 0.0
 normalized_value = (value / rounding_factor)
 epsilon_magnitude = math.log(abs(normalized_value), 2)
 epsilon = (2 ** (epsilon_magnitude - 53))
 if (rounding_method == 'HALF-UP'):
  normalized_value += (cmp(normalized_value, 0) * epsilon)
  rounded_value = round(normalized_value)
 elif (rounding_method == 'UP'):
  sign = cmp(normalized_value, 0)
  normalized_value -= (sign * epsilon)
  rounded_value = (math.ceil(abs(normalized_value)) * sign)
 result = (rounded_value * rounding_factor)
 return result

def float_round ( value , precision_digits = None , precision_rounding = None , rounding_method = 'HALF-UP' ) : rounding_factor = _float_check_precision ( precision_digits = precision_digits , precision_rounding = precision_rounding ) if ( ( rounding_factor == 0 ) or ( value == 0 ) ) : return 0.0 normalized_value = ( value / rounding_factor ) epsilon_magnitude = math . log ( abs ( normalized_value ) , 2 ) epsilon = ( 2 ** ( epsilon_magnitude - 53 ) ) if ( rounding_method == 'HALF-UP' ) : normalized_value += ( cmp ( normalized_value , 0 ) * epsilon ) rounded_value = round ( normalized_value ) elif ( rounding_method == 'UP' ) : sign = cmp ( normalized_value , 0 ) normalized_value -= ( sign * epsilon ) rounded_value = ( math . ceil ( abs ( normalized_value ) ) * sign ) result = ( rounded_value * rounding_factor ) return result
return value rounded to precision_digits decimal digits .