tests/float: Adjust float-parsing tests to pass with only a small error.

Float parsing (both single and double precision) may have a relative error
of order the floating point precision, so adjust tests to take this into
account by not printing all of the digits of the answer.
This commit is contained in:
Damien George
2018-02-26 15:54:03 +11:00
parent 4c2230add8
commit 6dad088569
2 changed files with 5 additions and 6 deletions

View File

@@ -11,9 +11,9 @@ print(float('.' + '9' * 400 + 'e100'))
print(float('.' + '9' * 400 + 'e-100'))
# tiny fraction with large exponent
print(float('.' + '0' * 400 + '9e100'))
print(float('.' + '0' * 400 + '9e200'))
print(float('.' + '0' * 400 + '9e400'))
print('%.14e' % float('.' + '0' * 400 + '9e100'))
print('%.14e' % float('.' + '0' * 400 + '9e200'))
print('%.14e' % float('.' + '0' * 400 + '9e400'))
# ensure that accuracy is retained when value is close to a subnormal
print(float('1.00000000000000000000e-307'))