示例#1
0
def roundup(ctx, number, num_digits):
    """
    Rounds a number up, away from zero
    """
    number = conversions.to_decimal(number, ctx)
    num_digits = conversions.to_integer(num_digits, ctx)

    return decimal_round(number, num_digits, ROUND_UP)
示例#2
0
def rounddown(ctx, number, num_digits):
    """
    Rounds a number down, toward zero
    """
    number = conversions.to_decimal(number, ctx)
    num_digits = conversions.to_integer(num_digits, ctx)

    return decimal_round(number, num_digits, ROUND_DOWN)
示例#3
0
def _round(ctx, number, num_digits):
    """
    Rounds a number to a specified number of digits
    """
    number = conversions.to_decimal(number, ctx)
    num_digits = conversions.to_integer(num_digits, ctx)

    return decimal_round(number, num_digits, ROUND_HALF_UP)
示例#4
0
def roundup(ctx, number, num_digits):
    """
    Rounds a number up, away from zero
    """
    number = conversions.to_decimal(number, ctx)
    num_digits = conversions.to_integer(num_digits, ctx)

    return decimal_round(number, num_digits, ROUND_UP)
示例#5
0
def rounddown(ctx, number, num_digits):
    """
    Rounds a number down, toward zero
    """
    number = conversions.to_decimal(number, ctx)
    num_digits = conversions.to_integer(num_digits, ctx)

    return decimal_round(number, num_digits, ROUND_DOWN)
示例#6
0
def _round(ctx, number, num_digits):
    """
    Rounds a number to a specified number of digits
    """
    number = conversions.to_decimal(number, ctx)
    num_digits = conversions.to_integer(num_digits, ctx)

    return decimal_round(number, num_digits, ROUND_HALF_UP)