If we have an octal number, e.g. 0o157, Perl 6 can convert it into decimal:
> 0o157
111
We are not permitted to remove this o in its octal representation:
> 0157
Potential difficulties:
Leading 0 has no meaning. If you meant to create an octal number, use '0o' prefix; like, '0o157'. If you meant to create a string, please add quotation marks.
------> 0157⏏<EOL>
Now let's make a reverse conversion, from decimal to octal:
> printf "%#o\n", 111
0157
The question is: why is there now no o after 0 in the octal representation?
Meanwhile, if we convert to hexadecimal, the x will be there:
> printf "%#x\n", 111
0x6f
The question is: why is there now no
oafter0in the octal representation?
(s)printf is a pretty universally used function, and ported directly to Perl 6. It is meant to be compatible with other languages' printf functions more than with Perl 6 input syntax.
Perl 5's printf behaves the same way, so its behavior was likely copied directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With