Unified rounding in all python versions.
541295
def py3round(number):
    """"""
    if abs(round(number) - number) == 0.5:
        return int(2.0 * round(number / 2.0))

    return int(round(number))
801623
def simple_round_factory(tol):
    """"""
    def simple_round(*args, **kwds):
        argstype = type(args)
        _args = list(args)
        _kwds = kwds.copy()
        for i,j in enumerate(args): # args[0] is the class.
            if isinstance(j, float): _args[i] = round(j, tol[i - 1] \
                if isinstance(tol, (list, tuple)) else tol) # don't round int
        for k, (i,j) in enumerate(kwds.items()):
            if isinstance(j, float): _kwds[i] = round(j, tol[k] \
                if isinstance(tol, (list, tuple)) else tol)
        return argstype(_args), _kwds
    return simple_round
1110069
def round_to_int(number, precision):
    """"""
    precision = int(precision)
    rounded = (int(number) + precision / 2) // precision * precision
    return rounded
939654
private static void scaleDownTenRoundUp(Slice decimal, int tenScale, Slice result)
    {
        boolean round;
        do {
            int powerTen = Math.min(tenScale, MAX_POWER_OF_TEN_INT);
            tenScale -= powerTen;

            int divisor = POWERS_OF_TEN_INT[powerTen];
            round = divideCheckRound(decimal, divisor, result);
            decimal = result;
        }
        while (tenScale > 0);

        if (round) {
            incrementUnsafe(decimal);
        }
    }
172597
def _round_multiple(x:int, mult:int=None)->int:
    ""
    return (int(x/mult+0.5)*mult) if mult is not None else x
659355
function round (amount, numOfDecDigits) {
        numOfDecDigits = numOfDecDigits || 2;
        return Math.round(amount * Math.pow(10, numOfDecDigits)) / Math.pow(10, numOfDecDigits);
    }
773417
def __to_float(val, digits):
    """"""
    try:
        return round(float(val), digits)
    except (ValueError, TypeError):
        return float(0)
894297
def round(digits = nil)
      rounded_value = digits ? value.round(digits) : value.round
      self.class.new(rounded_value, unit)
    end
569208
def teachers_round(x):
    '''
    
    '''
    if ((x > 0) and (x % 1 >= 0.5)) or ((x < 0) and (x % 1 > 0.5)):
        return int(np.ceil(x))
    else:
        return int(np.floor(x))
509536
def round_two_non_zero_dp(decimal):
    
    log10 = decimal.log10().to_integral_exact(rounding=ROUND_FLOOR) \
        if decimal else 0
    div = Decimal(10) ** (Decimal(1) - log10) if log10 < 0 else Decimal(100)
    return (decimal * div).to_integral_exact(rounding=ROUND_HALF_UP) / div
377981
def round_float(f, digits, rounding=ROUND_HALF_UP):
    
    return Decimal(str(f)).quantize(Decimal(10) ** (-1 * digits),
                                    rounding=rounding)
799495
function round(float, digits) {
		if(digits == null) {
			return Math.round(float);
		}
		var round = 10 * digits;
		return Math.round(float * round) / round;
	}
121059
def _recursive_round(self, value, precision):
        
        if hasattr(value, '__iter__'):
            return tuple(self._recursive_round(v, precision) for v in value)
        return round(value, precision)
179474
def _lerp(x, x0, x1, y0, y1):
  """"""
  return y0 + (x - x0) * float(y1 - y0) / (x1 - x0)
55674
def alpha(self):
        
        return round(
            float(
                self.calc_alpha(
                    self.annualize_return,
                    self.benchmark_annualize_return,
                    self.beta,
                    0.05
                )
            ),
            2
        )
804191
public static BigDecimal decimalRound(BigDecimal number, int numDigits, RoundingMode rounding) {
        BigDecimal rounded = number.setScale(numDigits, rounding);

        if (numDigits < 0) {
            rounded = rounded.setScale(0, BigDecimal.ROUND_UNNECESSARY);
        }

        return rounded;
    }
1043403
private double round(double value, int precision) {
    return BigDecimal.valueOf(value)
        .setScale(precision, RoundingMode.HALF_UP)
        .doubleValue();
  }