A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2018-July/154359.html below:

[Python-Dev] Examples for PEP 572

[Python-Dev] Examples for PEP 572 [Python-Dev] Examples for PEP 572Terry Reedy tjreedy at udel.edu
Thu Jul 5 01:13:13 EDT 2018
On 7/4/2018 2:32 PM, Sven R. Kunze wrote:
> Sorry for adding yet another mail. :-(
> 
> On 04.07.2018 10:54, Serhiy Storchaka wrote:
>> Sorry, this PEP was rewritten so many times that I missed your Appendix.
>>
>>> while total != (total := total + term):
>>>     term *= mx2 / (i*(i+1))
>>>     i += 2
>>> return total
>>
> 
> This very example here caught my eye.
> 
> Isn't total not always equal to total

Repeat response given elsewhere.  No.  Python has limited precision 
floats, not reals.  Floats do not obey laws of real numbers.

 >>> 1e50 + 1e34 == 1e50
True
 >>> 1e50 + 1e35 == 1e50
False

Basic numerical analysis operation: approximate infinite sum of 
decreasing terms by summing terms until they become small enough that 
they can be ignored.


-- 
Terry Jan Reedy


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4