-
Notifications
You must be signed in to change notification settings - Fork 577
[doc] perlnumber: Negative octal number as a string evaluates to decimal number in numeric operations #18583
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
Comments
"Negative octal number in a string" is not a thing. You can apply the unary minus to an octal numeric literal, as you do with |
If my thread name is misleading, feel free to suggest another, I can change.
|
Perl has native numbers and decimal number strings. There is no octal number string. perlnumber is very clear about this. Converting a string to a number works with decimal numbers only. Leading space is ignored. These all give the answer I expect:
The weird thing is the warning, and I expect there's a sequencing issue with the number conversion. Note that the last example issues no warning. Perl ignores the leading whitespace before the digits. It's also ignoring the leading whitespace the penultimate example, but it's already seen a non-digit character that is part of the number. |
Also, see #18595 |
I think that strings beginning with "0"are being regarded as decimal numbers, and the leading "0" is simply being (correctly) ignored.
That warning looks to be unrelated to the leading "0".
I don't know if those 2 one-liners should emit the non-numeric warning. or not. |
Here are a few other tickets that seem to be related:
|
Where
https://perldoc.perl.org/perlnumber#SYNOPSIS
Description
Seems undocumented behavior. Quoted negative octal number evaluates to decimal:
(perl v5.32.0)
OUTPUT:
The text was updated successfully, but these errors were encountered: