Look at the official documentation:
"Returns the integer portion of EXPR"
That's incorrect and vague
- NaN and Inf are not integers
- What does 'integer portion' actually mean? It's not defined, so one could read that to mean that the integer portion of eee5 is 5
At the very least, this documentation needs fixing - even if the underlying code is not getting touched.
| [reply] [d/l] |
NaN and Inf are not integers
That's true - for completeness, the documentation should probably specify that int($x) returns $x, as evaluated in numeric context, if $x (as evaluated in numeric context) is either NaN or +Inf or -Inf or has no fractional part.
What does 'integer portion' actually mean? It's not defined, so one could read that to mean that the integer portion of eee5 is 5.
Maybe it should be specified that EXPR is first evaluated in numeric context, and the integer portion of that derived value is returned.
But then, neither the sin() nor cos() nor log() nor exp() nor sqrt() documentations specify that EXPR is to be evaluated in numeric context.
Do those docs need to make the same clarification ?
One might argue that it's somehow already clear that those math functions will evaluate their args in numeric context, but that it's not immediately apparent that int() will do the same.
I don't think I'd agree with that argument ... nor would I necessarily disagree with it ... dunno ;-)
You should present you point of view at https://github.com/Perl/perl5/pull/22227.
Cheers, Rob
| [reply] [d/l] |