This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Python Language Reference Documentation
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: ArnuldOnData, docs@python, mark.dickinson, miss-islington, rhettinger, steven.daprano, stutzbach
Priority: normal Keywords: patch

Created on 2020-04-04 03:36 by ArnuldOnData, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
Screenshot_2020-04-04 6 Expressions — Python 3 8 2 documentation.png ArnuldOnData, 2020-04-04 03:36 A screenshot where the bug is highlighted
Pull Requests
URL Status Linked Edit
PR 19357 merged mark.dickinson, 2020-04-04 09:33
PR 19383 merged miss-islington, 2020-04-05 09:30
PR 19384 merged miss-islington, 2020-04-05 09:31
Messages (5)
msg365742 - (view) Author: Arnuld (ArnuldOnData) * Date: 2020-04-04 03:36
In section "6.10.1 Value comparisons", it is written:

https://docs.python.org/3/reference/expressions.html

"The not-a-number values float('NaN') and decimal.Decimal('NaN') are
special. Any ordered comparison of a number to a not-a-number value is
false. A counter-intuitive implication is that not-a-number values are
not equal to themselves. For example, if x = float('NaN'), 3 < x, x <
3, x == x, x != x are all false. This behavior is compliant with IEEE
754."

Last comparison "x != x" does not return False, it returns True. Here is the output from my iPython interpeter I am using on Arch Linux (latest as of today):

In [86]: x == y
Out[86]: False

In [87]: x != y
Out[87]: True


I verified the bug it on Wikipedia too:

https://en.wikipedia.org/wiki/NaN#Comparison_with_NaN
msg365746 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2020-04-04 04:36
How about this?


"The not-a-number values ``float('NaN')`` and ``decimal.Decimal('NaN')`` are
special. Not-a-number values always compare unordered and unequal to any other value, including themselves. For example, if ``x = float('NaN')``, then ``x == x``, ``3 < x``, and ``x < 3`` are all false, but ``x != x`` is true. This behavior is compliant with the IEEE 754 standard."


Due to technology problems at my end, I cannot submit a PR for this, but this should be an easy issue. If somebody wants to use the text above as a start, please feel free to do so.
msg365747 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2020-04-04 04:38
Oops, that should be

    ... ``x == x``, ``3 < x``, and ``x > 3`` are all false ...
msg365748 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2020-04-04 04:39
Oh never mind, I'm just going to slink away now and stop posting corrections when distracted...
msg365815 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2020-04-05 09:57
Thanks for the report! Now fixed.
History
Date User Action Args
2022-04-11 14:59:29adminsetgithub: 84358
2020-04-05 09:57:57mark.dickinsonsetstatus: open -> closed
type: enhancement -> behavior
messages: + msg365815

resolution: fixed
stage: patch review -> resolved
2020-04-05 09:31:04miss-islingtonsetpull_requests: + pull_request18747
2020-04-05 09:30:43miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request18746
2020-04-04 09:33:11mark.dickinsonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request18718
2020-04-04 04:39:49steven.dapranosetmessages: + msg365748
2020-04-04 04:38:48steven.dapranosetmessages: + msg365747
2020-04-04 04:36:27steven.dapranosetnosy: + steven.daprano
messages: + msg365746
2020-04-04 03:44:09xtreaksetnosy: + rhettinger, mark.dickinson, stutzbach
2020-04-04 03:36:05ArnuldOnDatacreate