skip to Main Content

I was wondering if I could quickly remove the 0 from 01232 by dividing it by 1 in my browsers console but all of a sudden it gives me 666.

Opera GX Browser Console

So I was curious and tried this.

enter image description here

2

Answers


  1. Because the leading zero makes the whole number be treated as octal

    And 2 + 3×8 + 2×8^2 + 1×8^3 = 666

    Login or Signup to reply.
  2. The leading 0 in 01232 means that the rest of the number is interpreted as octal, representing

    1 x 8^3   +   2 x 8^2   +   3 x 8^1   +   2 x 8^0
    
    =
    
    512 + 128 + 24 + 2
    
    =
    
    666 
    

    This prefix (analogous to 0x for hexadecimal) dates back to the early days of Unix; see here.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search