@@ -1307,9 +1307,11 @@ def str_to_man_exp(x, base=10):
|
||||
parts = x.split(sep)
|
||||
if len(parts) == 1:
|
||||
exp = 0
|
||||
else: # == 2
|
||||
elif len(parts) == 2:
|
||||
x = parts[0]
|
||||
exp = int(parts[1])
|
||||
else:
|
||||
raise ValueError("couldn't convert a str to mpf")
|
||||
# Look for radix point in mantissa
|
||||
parts = x.split('.')
|
||||
if len(parts) == 2:
|
||||
|
||||
@@ -79,6 +79,7 @@ def test_to_str():
|
||||
x = mpf('1234.567891')._mpf_
|
||||
pytest.raises(ValueError, lambda: to_str(x, 6, binary_exp=True))
|
||||
pytest.raises(ValueError, lambda: to_str(x, 6, rounding='Y'))
|
||||
pytest.raises(ValueError, lambda: to_str('1e400e2', 6))
|
||||
assert to_str(x, 5, rounding='n') == '1234.6'
|
||||
assert to_str(x, 5, rounding='d') == '1234.5'
|
||||
assert to_str(x, 5, rounding='u') == '1234.6'
|
||||
|
||||
Reference in New Issue
Block a user