New submission from Karthikeyan Singaravelan <tir.kar...@gmail.com>:

There have been tickets raised due to floating point representation being 
misleading where "0.1 + 0.2" returns 0.30000000000000004 and "0.1 + 0.3" 
returns 0.4. This is explained at [0] but I think it's worth to add this as a 
question to FAQ and link to the tutorial and possibly to some external links 
like [1] and [2] so that the user can understand the limitation instead of 
assuming it's a bug in CPython. Searching for "floatingpoint.html" gives 64 
issues [4] were the documentation was linked out of which 3 were reported in 
the past one month.

If there is also any other page where this can be linked to get better 
visibility then this could avoid a lot of confusion especially for beginners 
where "0.1 + 0.3" silently seems to work fine but "0.1 + 0.2" has a misleading 
representation along with variations in other floating point arithmetic 
operations making the user think it's a CPython bug.

Adding Raymond to see if it's worth adding it in FAQ or any other place and 
also that he might have more feedback on teaching users and wording this in a 
better way.

[0] https://docs.python.org/3/tutorial/floatingpoint.html
[1] https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
[2] https://0.30000000000000004.com/
[4] 
https://bugs.python.org/issue?%40columns=id%2Cactivity%2Ctitle%2Ccreator%2Cassignee%2Cstatus%2Ctype&%40sort=-activity&%40filter=status&%40action=searchid&ignore=file%3Acontent&%40search_text=floatingpoint.html&submit=search&status=-1%2C1%2C2%2C3

----------
assignee: docs@python
components: Documentation
messages: 327390
nosy: docs@python, rhettinger, xtreak
priority: normal
severity: normal
status: open
title: Add an FAQ note about floating point representation
versions: Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34942>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to