Precision Tail-off?

Weatherby,Gerard gweatherby at uchc.edu
Tue Feb 14 07:58:42 EST 2023


Use Python3

Use the decimal module:  https://docs.python.org/3/library/decimal.html


From: Python-list <python-list-bounces+gweatherby=uchc.edu at python.org> on behalf of Stephen Tucker <stephen_tucker at sil.org>
Date: Tuesday, February 14, 2023 at 2:11 AM
To: Python <python-list at python.org>
Subject: Precision Tail-off?
*** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***

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
----------------------------------------------
--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!kSE4mNp5KxTEp6SKzpQeBukScLYsmEoDfLpSTuc2Zv8Z3pZQhTm0usq-k4eVquxM08u8VSUX1X6id9IICJHA2B4mzw$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!kSE4mNp5KxTEp6SKzpQeBukScLYsmEoDfLpSTuc2Zv8Z3pZQhTm0usq-k4eVquxM08u8VSUX1X6id9IICJHA2B4mzw$>


More information about the Python-list mailing list