示例#1
0
文件: test_rdtoa.py 项目: Mu-L/pypy
def test_dtoa():
    assert dtoa(3.47) == "3.47"
    assert dtoa(1.1) == "1.1"
    assert dtoa(-1.1) == "-1.1"
    assert dtoa(1.1, flags=rfloat.DTSF_SIGN) == "+1.1"
    assert dtoa(12.3577) == "12.3577"
    assert dtoa(10.0) == "10"
    assert dtoa(1.0e100) == "1e+100"

    assert dtoa(rfloat.INFINITY) == 'inf'
    assert dtoa(-rfloat.INFINITY) == '-inf'
    assert dtoa(rfloat.NAN) == 'nan'
示例#2
0
def test_dtoa():
    assert dtoa(3.47) == "3.47"
    assert dtoa(1.1) == "1.1"
    assert dtoa(-1.1) == "-1.1"
    assert dtoa(1.1, flags=rfloat.DTSF_SIGN) == "+1.1"
    assert dtoa(12.3577) == "12.3577"
    assert dtoa(10.0) == "10"
    assert dtoa(1.0e100) == "1e+100"

    assert dtoa(rfloat.INFINITY) == 'inf'
    assert dtoa(-rfloat.INFINITY) == '-inf'
    assert dtoa(rfloat.NAN) == 'nan'
示例#3
0
文件: test_rdtoa.py 项目: Mu-L/pypy
def test_flag_cut_exp_0():
    assert dtoa(1.1e9, code="g", precision=2,
                flags=rfloat.DTSF_CUT_EXP_0) == "1.1e+9"
    assert dtoa(1.1e-9, code="g", precision=2,
                flags=rfloat.DTSF_CUT_EXP_0) == "1.1e-9"
示例#4
0
文件: test_rdtoa.py 项目: Mu-L/pypy
def test_dtoa_precision():
    assert dtoa(1.1, code='f', precision=2) == "1.10"
    assert dtoa(1e12, code='g', precision=12) == "1e+12"
示例#5
0
文件: number.py 项目: mio-lang/mio
 def repr(self):
     return dtoa(self.value)
示例#6
0
def test_dtoa_precision():
    assert dtoa(1.1, code='f', precision=2) == "1.10"
    assert dtoa(1e12, code='g', precision=12) == "1e+12"
示例#7
0
def test_flag_cut_exp_0():
    assert dtoa(1.1e9, code="g", precision=2, flags=rfloat.DTSF_CUT_EXP_0) == "1.1e+9"
    assert dtoa(1.1e-9, code="g", precision=2, flags=rfloat.DTSF_CUT_EXP_0) == "1.1e-9"