コード例 #1
0
def test_r_round():
    eq_(r_round(1.0), 1.0)
    eq_(r_round(1.0, rounding='E-12'), 1.0)
    eq_(r_round(1.01, rounding='E-12'), 1.0)
    eq_(r_round(1.19, rounding='E-12'), 1.2)
    eq_(r_round(9.9, rounding='E-12'), 10)
    eq_(r_round(400, rounding='E-12'), 390)
    eq_(r_round(0.0046, rounding='E-12'), 0.0047)
コード例 #2
0
def test_r_round():
    eq_(r_round(1.0), 1.0)
    eq_(r_round(1.0, rounding='E-12'), 1.0)
    eq_(r_round(1.01, rounding='E-12'), 1.0)
    eq_(r_round(1.19, rounding='E-12'), 1.2)
    eq_(r_round(9.9, rounding='E-12'), 10)
    eq_(r_round(400, rounding='E-12'), 390)
    eq_(r_round(0.0046, rounding='E-12'), 0.0047)
コード例 #3
0
def format_ohmE12(x):
    x = r_round(x, rounding='E-12')
    (x, prefix) = round_value(x)
    postfix = OMEGA
    if x >= 10:
        format_str = '%0.0f %s%s'
    elif x >= 1:
        format_str = '%0.1f %s%s'
    else:
        format_str = '%0.2f %s%s'
    return format_str % (x, prefix, postfix)
コード例 #4
0
def format_ohmE12(x):
    x=r_round(x, rounding='E-12')
    (x, prefix) = round_value(x)
    postfix = OMEGA
    if x >= 10:
        format_str = '%0.0f %s%s'
    elif x >= 1:
        format_str = '%0.1f %s%s'
    else:
        format_str = '%0.2f %s%s'
    return format_str % (x, prefix, postfix)