title: Converting to and from octal in Perl 6
body: <p>If we have an octal number, e.g. <code>0o157</code>, Perl 6 can convert it into decimal:</p>
  
  <pre class="lang-perl6 prettyprint-override"><code>&gt; 0o157
  111
  </code></pre>
  
  <p>We are not permitted to remove this <code>o</code> in its octal representation:</p>
  
  <pre class="lang-perl6 prettyprint-override"><code>&gt; 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.
      ------&gt; 0157⏏&lt;EOL&gt;
  </code></pre>
  
  <p>Now let's make a reverse conversion, from decimal <a href="https://docs.perl6.org/type/Str#sub_sprintf" rel="noreferrer">to octal</a>: </p>
  
  <pre class="lang-perl6 prettyprint-override"><code>&gt; printf "%#o\n", 111
  0157
  </code></pre>
  
  <p>The question is: why is there now no <code>o</code> after <code>0</code> in the octal representation?</p>
  
  <p>Meanwhile, if we convert to hexadecimal, the <code>x</code> will be there:</p>
  
  <pre class="lang-perl6 prettyprint-override"><code>&gt; printf "%#x\n", 111
  0x6f
  </code></pre>