Precision Tail-off?

Stephen Tucker stephen_tucker at sil.org
Tue Feb 14 02:09:37 EST 2023


Hi,

I have just produced the following log in IDLE (admittedly, in Python
2.7.10 and, yes I know that it has been superseded).

It appears to show a precision tail-off as the supplied float gets bigger.

I have two questions:
1. Is there a straightforward explanation for this or is it a bug?
2. Is the same behaviour exhibited in Python 3.x?

For your information, the first 20 significant figures of the cube root in
question are:
   49793385921817447440

Stephen Tucker.
----------------------------------------------
>>> 123.456789 ** (1.0 / 3.0)
4.979338592181744
>>> 123456.789 ** (1.0 / 3.0)
49.79338592181744
>>> 123456789. ** (1.0 / 3.0)
497.9338592181743
>>> 123456789000. ** (1.0 / 3.0)
4979.338592181743
>>> 123456789000000. ** (1.0 / 3.0)
49793.38592181742
>>> 123456789000000000. ** (1.0 / 3.0)
497933.8592181741
>>> 123456789000000000000. ** (1.0 / 3.0)
4979338.59218174
>>> 123456789000000000000000. ** (1.0 / 3.0)
49793385.9218174
>>> 123456789000000000000000000. ** (1.0 / 3.0)
497933859.2181739
>>> 123456789000000000000000000000. ** (1.0 / 3.0)
4979338592.181739
>>> 123456789000000000000000000000000. ** (1.0 / 3.0)
49793385921.81738
>>> 123456789000000000000000000000000000. ** (1.0 / 3.0)
497933859218.1737
>>> 123456789000000000000000000000000000000. ** (1.0 / 3.0)
4979338592181.736
>>> 123456789000000000000000000000000000000000. ** (1.0 / 3.0)
49793385921817.36
>>> 123456789000000000000000000000000000000000000. ** (1.0 / 3.0)
497933859218173.56
>>> 123456789000000000000000000000000000000000000000. ** (1.0 / 3.0)
4979338592181735.0
>>> 123456789000000000000000000000000000000000000000000. ** (1.0 / 3.0)
4.979338592181734e+16
>>> 123456789000000000000000000000000000000000000000000000. ** (1.0 / 3.0)
4.979338592181734e+17
>>> 123456789000000000000000000000000000000000000000000000000. ** (1.0 /
3.0)
4.979338592181733e+18
>>> 123456789000000000000000000000000000000000000000000000000000. ** (1.0 /
3.0)
4.979338592181732e+19
>>> 123456789000000000000000000000000000000000000000000000000000000. **
(1.0 / 3.0)
4.9793385921817313e+20
----------------------------------------------


More information about the Python-list mailing list