Message415929
> "Due to the requirements of the `IEEE-754 standard <https://en.wikipedia.org/wiki/IEEE_754>`_, math.nan and float('nan') are never equal to any other value, including themselves. Use math.isnan to test for NANs."
It seems to me, Steven's description is clear enough to tell us that "Be careful if you want to compare NANs with others".
One thing to emphasize is that neither `is` nor `==` is a best practice, just like slateny's example, we should be wary of the difference between `float('nan')` and `math.nan`.
Adding an example to the docs would be a good way to let everyone know the difference and use `math.isnan` instead of `is` and `==` to test for NANs. |
|
Date |
User |
Action |
Args |
2022-03-24 09:02:20 | CharlieZhao | set | recipients:
+ CharlieZhao, steven.daprano, docs@python, serhiy.storchaka, veky, slateny |
2022-03-24 09:02:19 | CharlieZhao | set | messageid: <1648112539.95.0.269044150679.issue47031@roundup.psfhosted.org> |
2022-03-24 09:02:19 | CharlieZhao | link | issue47031 messages |
2022-03-24 09:02:19 | CharlieZhao | create | |
|