Fix isfinite to return false for NaN (#3510)

`isfinite` checked only for infinities, so `nan | isfinite` was true
and `finites` let NaN through. A finite number is neither infinite nor
NaN, as in C's `isfinite`, `Number.isFinite` and `math.isfinite`.
This commit is contained in:
cui authored and GitHub committed 2026-12-03 16:36:02 +09:00
1 parent 5cd5edb2e9
commit bf1da84499
4 files changed
+17 -4

No files matched your search

+3 -2
View File
@@ -1523,8 +1523,9 @@ sections:
if its input is infinite. The `isnan` builtin returns `true`
if its input is a NaN. The `infinite` builtin returns a
positive infinite value. The `nan` builtin returns a NaN.
The `isnormal` builtin returns true if its input is a normal
number.
The `isfinite` builtin returns `true` if its input is a number
that is neither infinite nor a NaN. The `isnormal` builtin
returns true if its input is a normal number.
Note that division by zero raises an error.