コード例 #1
0
ファイル: test_rdtoa.py プロジェクト: njues/Sypy
def test_strtod():
    assert strtod("12345") == 12345.0
    assert strtod("1.1") == 1.1
    assert strtod("3.47") == 3.47
    assert strtod(".125") == .125
    raises(ValueError, strtod, "123A")
    raises(ValueError, strtod, "")
    raises(ValueError, strtod, " ")
    raises(ValueError, strtod, "\0")
    raises(ValueError, strtod, "3\09")
コード例 #2
0
ファイル: test_rdtoa.py プロジェクト: Debug-Orz/Sypy
def test_strtod():
    assert strtod("12345") == 12345.0
    assert strtod("1.1") == 1.1
    assert strtod("3.47") == 3.47
    assert strtod(".125") == .125
    raises(ValueError, strtod, "123A")
    raises(ValueError, strtod, "")
    raises(ValueError, strtod, " ")
    raises(ValueError, strtod, "\0")
    raises(ValueError, strtod, "3\09")
コード例 #3
0
ファイル: rfloat.py プロジェクト: purepython/pypy
def rstring_to_float_impl(s):
    if USE_SHORT_FLOAT_REPR:
        from pypy.rlib.rdtoa import strtod
        return strtod(s)
    sign, before_point, after_point, exponent = break_up_float(s)
    if not before_point and not after_point:
        raise ValueError
    return parts_to_float(sign, before_point, after_point, exponent)
コード例 #4
0
ファイル: rfloat.py プロジェクト: gorakhargosh/pypy
def rstring_to_float_impl(s):
    if USE_SHORT_FLOAT_REPR:
        from pypy.rlib.rdtoa import strtod
        return strtod(s)
    sign, before_point, after_point, exponent = break_up_float(s)
    if not before_point and not after_point:
        raise ValueError
    return parts_to_float(sign, before_point, after_point, exponent)