-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document the behaviour of int("NaN") #22227
base: blead
Are you sure you want to change the base?
Conversation
There are still people surprised by it, e.g. https://www.perlmonks.org/?node_id=11159579
pod/perlfunc.pod
Outdated
the L<C<sprintf>|/sprintf FORMAT, LIST>, | ||
because it's really more like -268.99999999999994315658 instead. | ||
Similarly, C<int "Info"> produces Inf, see | ||
L<perldata/Special floating point: infinity (Inf) and not-a-number (NaN)> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really "similar" to the above? Floating point accuracy seems unrelated to how Perl doesn't force the result of int
to be an integer.
While the link addresses the string conversion to a float, nothing in it or this text address how for numbers outside the integer range, perl will still return a float. And while mathematically 1e50
is an integer even if internally stored as a float, Inf and NaN are definitely not integers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's similar because it "can sometimes produce counterintuitive results". But I agree the wording could be improved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with a fixup. Let me know if I should squash the changes.
The change here seems to be trying to document two issues at the same time. It's documenting that "Info" gets numified into inf, but this has little to do with int. It's also documenting that int(inf) still produces an inf. That seems like the relevant thing to be focusing on here. I feel like using |
Ok, removed the "o" in "Info". Another fixup. |
There are still people surprised by it, e.g.
https://www.perlmonks.org/?node_id=11159579