(op1, op2, prec = 0)
return op1, op2
Normalizes op1, op2 to have the same exp and length of coefficient.

    Done during addition.
Normalizes op1, op2 to have the same exp and length of coefficient.
Normalizes op1 op2 to have the same exp and length of coefficient .
def _normalize(op1, op2, prec = 0):
    """Normalizes op1, op2 to have the same exp and length of coefficient.

    Done during addition.
    """
    if op1.exp < op2.exp:
        tmp = op2
        other = op1
    else:
        tmp = op1
        other = op2

    # Let exp = min(tmp.exp - 1, tmp.adjusted() - precision - 1).
    # Then adding 10**exp to tmp has the same effect (after rounding)
    # as adding any positive quantity smaller than 10**exp; similarly
    # for subtraction.  So if other is smaller than 10**exp we replace
    # it with 10**exp.  This avoids tmp.exp - other.exp getting too large.
    tmp_len = len(str(tmp.int))
    other_len = len(str(other.int))
    exp = tmp.exp + min(-1, tmp_len - prec - 2)
    if other_len + other.exp - 1 < exp:
        other.int = 1
        other.exp = exp

    tmp.int *= 10 ** (tmp.exp - other.exp)
    tmp.exp = other.exp
    return op1, op2
def _normalize ( op1 , op2 , prec = 0 ) : if op1 . exp < op2 . exp : tmp = op2 other = op1 else : tmp = op1 other = op2 # Let exp = min(tmp.exp - 1, tmp.adjusted() - precision - 1). # Then adding 10**exp to tmp has the same effect (after rounding) # as adding any positive quantity smaller than 10**exp; similarly # for subtraction.  So if other is smaller than 10**exp we replace # it with 10**exp.  This avoids tmp.exp - other.exp getting too large. tmp_len = len ( str ( tmp . int ) ) other_len = len ( str ( other . int ) ) exp = tmp . exp + min ( - 1 , tmp_len - prec - 2 ) if other_len + other . exp - 1 < exp : other . int = 1 other . exp = exp tmp . int *= 10 ** ( tmp . exp - other . exp ) tmp . exp = other . exp return op1 , op2