|
19 | 19 | print(float("1.00000000000000000000e-307"))
|
20 | 20 | print(float("10.0000000000000000000e-308"))
|
21 | 21 | print(float("100.000000000000000000e-309"))
|
| 22 | + |
| 23 | +# ensure float is parsed exactly |
| 24 | +print(float("74e46")) |
| 25 | + |
| 26 | +# Overflow/largest double boundary: |
| 27 | +print(float("1.7976931348623159e308")) # (should overflow, 0x000000000000f07f ) |
| 28 | +print("%.15e" % float("1.7976931348623158e308")) # (should yield the max double, 0xffffffffffffef7f ) |
| 29 | + |
| 30 | +""" |
| 31 | +TODO get these working? |
| 32 | +# Normalized/denormalized double boundary |
| 33 | +print("%.16e" % float("2.2250738585072012e-308")) # (should yield smallest normalized double, 0x0000000000001000 ) |
| 34 | +print("%.16e" % float("2.2250738585072011e-308")) # (should yield largest denormalized double, 0xffffffffffff0f00 ) |
| 35 | +
|
| 36 | +# Shortest (up to) 17-digit input that converts to smallest denormalized double: |
| 37 | +print(float("5e-324")) # (should yield smallest denormalized double, 0x0100000000000000 ) |
| 38 | +
|
| 39 | +# Closest 17-digit input to the smallest denormalized double: |
| 40 | +print(float("4.9406564584124654e-324")) # (should yield smallest denormalized double, 0x0100000000000000 ) |
| 41 | +
|
| 42 | +# The next boundary will depend on how good the ldexp implementation is on the target platform: |
| 43 | +# Smallest denormalized double/underflow boundary: |
| 44 | +
|
| 45 | +print(float("2.4703282292062328e-324")) # (should yield smallest denormalized double, 0x0100000000000000 ) |
| 46 | +# (Note that this value is greater than 2**-1075 and therefore should round up. 64-bit CPython 3.7.5 on win32 gets this right. Your mileage may vary, since the 54 most significant bits of the result are 0b1.00000000000000000000000000000000000000000000000000000 x 2**-1075.) |
| 47 | +""" |
| 48 | + |
| 49 | +print(float("2.4703282292062327e-324")) # (should underflow to zero: 0x0000000000000000 ) |
| 50 | +# (Note that this value is less than 2**-1075 and therefore should round down to zero.) |
0 commit comments