[issue47020] float('nan')==math.nan does NOT evaluate to True (as suggested by documentation).

2022-03-14 Thread Eric V. Smith


Eric V. Smith  added the comment:

Jelle gives the correct reason for what you're seeing.

Also note:

>>> math.nan == math.nan
False
>>> float('nan') == float('nan')
False

If there's some specific part of the documentation that you think is 
misleading, please reopen this and point us to the wording that's confusing.

--
nosy: +eric.smith
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47020] float('nan')==math.nan does NOT evaluate to True (as suggested by documentation).

2022-03-14 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

I'm guessing you're referring to 
https://docs.python.org/3.8/library/math.html#math.nan. The text says 
explicitly that math.nan is "equivalent" to float("nan"), not that it is equal. 
This is correct.

nan is not equal to itself, because (for better or worse) that's what the IEEE 
standard requires. You can instead use math.isnan() to check whether a number 
is a nan.

--
nosy: +JelleZijlstra

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47020] float('nan')==math.nan does NOT evaluate to True (as suggested by documentation).

2022-03-14 Thread Pablo Dumas


New submission from Pablo Dumas :

float('nan')==math.nan  does NOT evaluate to True (as suggested by 
documentation).
On the other hand, float('inf')==math.inf  DOES evaluate to True (as 
suggested by documentation).

Documentation we're referring to: https://docs.python.org/3.8/library/math.html

--
assignee: docs@python
components: Documentation
messages: 415213
nosy: docs@python, w0rthle$$
priority: normal
severity: normal
status: open
title: float('nan')==math.nan  does NOT evaluate to True (as suggested by 
documentation).
type: behavior
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com