-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed as not planned
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
x = float("NaN")
# Prints "1.0"
print(x**0.0)
# Prints "nan"
print(x*0.0)
# Prints "nan"
print(x/float("inf"))
# Prints "nan"
print(x+float("inf"))
# Prints "nan"
print(x-float("inf"))
As you can see, the behavior of ** is inconsistent with that of * and +. ** treats NaN like a normal number,
so NaN ** 0.0 = 1.0. But other operations like * and + treat NaN like a special value, since it is not a number.
Therefore, the result of operations like NaN * 0.0 are NaN.
"""
CPython versions tested on:
3.13, 3.11
Operating systems tested on:
Windows
Metadata
Metadata
Assignees
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error