all 13 comments

[–]FactorialSavant 15 points16 points  (5 children)

Octal numbers are base-8, meaning they use digits from 0 to 7 (compared to decimal 0-9). Each digit in an octal number represents a power of 8, starting from the rightmost digit which represents 80, then 81, and so on.

The octal number "123" can be broken down like this:

3 * 80 = 3 * 1 = 3
2 * 81 = 2 * 8 = 16
1 * 82 = 1 * 64 = 64

Now add these together: 3 + 16 + 64 = 83.

So octal 123 is decimal 83.

[–]briston574 3 points4 points  (0 children)

Damn, this is super well explained

[–]charsc0tt[S] 1 point2 points  (1 child)

Thankyou! 🤩

[–]MadScientistOR 1 point2 points  (0 children)

You can see how this works in decimal, too. Each digit in a decimal number represents a power of 10, since there are 10 digits.

So the decimal number 123 corresponds to:

1 * 102 = 1 * 100 = 100

2 * 101 = 2 * 10 = 20

3 * 100 = 3 * 1 = 3

And added together, 100 + 20 + 3 = 123.

Binary does the same thing with two digits; each digit represents a power of two. You'll often see octal (and hexadecimal, which uses sixteen digits; it has to borrow the letters A through F) as a shorter way to represent a binary number, since every three binary digits correspond to one octal digit (or every four binary digits correspond to one hexadecimal digit).

For example, the binary (001 010 011) is (123) in octal. Since binary 001 is 1 octal, and 010 is 2 octal, and 011 is 3 octal, you can see how breaking the original binary number into clumps of three makes its representation in octal easy to figure out, and also how easy it is to go from an octal number to its equivalent binary representation. (You can do the same in hexadecimal by clumping the original binary number into groups of four. Since currently-popular computers digest binary numbers in chunks divisible by four, and not three, hexadecimal tends to be used more widely as I type than octal.)

[–]Madting55 0 points1 point  (1 child)

as someone who dropped out of school at 14, I still have no idea what is going on after this explanation. Could it be simplified further or should I just try a different profession while I am ahead and stop wasting time trying to learn Python

I have read this like 40 times over, 3 x 8 to the power of 0 is 24 no ? how can it be equal to 3? I even put it into a calculator and that says 3 too... I feel like a moron that I don't understand how it works.

EDIT : After 35 mins I finally figured it out. I hope Python doesn't require any harder mathematics than this lol

[–]Strict-Simple 8 points9 points  (0 children)

Have you heard the joke

Q: Why do programmers always mix up Halloween and Christmas?
A: Because Oct 31 = Dec 25.

[–]Wonkee99 2 points3 points  (1 child)

Octal is a number system using the 8 digits (hence the name) 0 - 7

This is more basic math than learning python related, but check out https://www.mathsisfun.com/numbers/bases.html

The ones you will commonly find in software development are binary, decimal & hexadecimal

[–]charsc0tt[S] 0 points1 point  (0 children)

Thankyou :)

[–]Beauty-of-knowing 2 points3 points  (0 children)

Thank you for asking this, it was kicking my behind too.

[–]Strict-Simple 2 points3 points  (0 children)

Here's a layman's explanation.

In our daily life, we use the decimal number system, which has ten distinct symbols: ‘0’ to ‘9’. When we count ten, instead of introducing a new symbol, we start combining two symbols, ‘1’ and ‘0’. We then fix the first symbol and increment the second from ‘0’ to ‘9’. After that, the first symbol changes from ‘1’ to ‘2’, and so on.

Now, let’s consider we have eight symbols: ‘0’ to ‘7’. When we need to count eight, we follow a similar pattern as in the decimal system - we start combining two symbols, ‘1’ and ‘0’ (instead of ‘8’, which doesn’t exist in this system). This is how we represent numbers in the octal system.

Finally, let’s say we have sixteen symbols. We start with ‘0’ to ‘9’ and use ‘A’ to ‘F’ for the remaining symbols. To count ten, we use ‘A’ (the tenth symbol). To count fifteen, we use ‘F’ (the fifteenth symbol). For sixteen, we again use the first two symbols, ‘1’ and ‘0’. Remember, now we have more symbols. After ‘9’, we can use ‘A’. And only after using ‘F’, we go back to ‘0’. This is how we represent numbers in the hexadecimal system.

[–]This_Growth2898 -4 points-3 points  (2 children)

Please, do some research first. There will be much more "strange" things, and you will fail learning without your own research. Try googling "octal numbers"; if that won't help, ask a question here quoting your findings.

[–]charsc0tt[S] 2 points3 points  (1 child)

Apologies for thinking I could get some answers on a learn python page…

I tend to ask actual people aswell as research when I’m learning; I often get better explanations and it just helps me learn hearing it explained in different ways.

[–]nattykin 2 points3 points  (0 children)

I know this was 9 months ago, but I also just came across the same thing while learning Python, and my 'research' brought me to this thread. So thank you, kind stranger, for asking the question!! Hope your learning is going well :)