Course Content
Numeral Systems 101
Numeral Systems 101
Get Acquainted with the Octal Numeral System
There is another numeral system called octal. In comparison to binary or decimal, it consists of 8 digits, starting with zero: 0
,1
,2
,3
,4
,5
,6
,7
.
If you wonder why it was implemented, I want to clarify something.
Usage
As you remember the number in binary representation consists of several digits, one bite for each of them; but in an octal numeral system, three binary digits represent one octal. Therefore, you can represent one word for the computer using fewer symbols. Enormous strings of binary code can be represented in a more beautiful way for the computer; hence, less memory is filled. The principle of converting a number to the decimal system from octal one is the same as with binary:As you remember the number in binary representation consists of several digits, one bite for each of them; but in an octal numeral system, three binary digits represent one octal. Therefore, you can represent one word for the computer using fewer symbols. Enormous strings of binary code can be represented in a more beautiful way for the computer; hence, less memory is filled. The principle of converting a number to the decimal system from octal one is the same as with binary:
Rule
Algorithms of converting to decimal numeral system overlap for different numeral systems. Here is the same for octal number 221: the index of the left number 2 is 2, the index of the middle number 2 is 1 and the index of the number 1 is zero; but here we should multiply the numbers by 8 raised to the power of index. Hence, 221
-> 2*8^2
+2*8^1
+2*8^0
=128
+16
+2
=146
.
# Defining the octal number octal_number = 221 # Creating a variable for storing the converted decimal number decimal_number = 0 # The text should be realised here due to the reason that further the binary number will be changed print("The number in octal numeral system is: ", octal_number) # Creating value for working with the power of a number power = 0 # The loop executes till the number is not null while octal_number != 0: # Separating the last digit of octal_number using the remainder of the division operation last_digit = octal_number % 10 # Multiply last_digit by 8 raised to the relevant power result = last_digit * pow(8, power) # Adding the result to the decimal number decimal_number = decimal_number + result # This operation of integer division decreases a number and put aside the last digit that was already used octal_number = octal_number // 10 # Increasing iterator to work with the power power = power + 1 # Printing the result print("The number in decimal numeral system is: ", decimal_number)
Task
Doing as many tasks as possible is a recipe for success! Write the code that will decode the number 117 from the octal numeral system to decimal. Fill the gaps and follow the algorithm. If everything is correct you will receive one special number 🧐 But the explanation is waiting for you at the end of this chapter.
- Print the
octal_number
. - Define the loop which goes through the
octal_number
variable till it is zero. - Assign the remainder of division
octal_number
by10
to the variable last_digit. - Multiply the received
last_digit
by the8
raised to the relevant power. - Decrease the
octal_number
using integer division by10
. - Increase the
power
by1
. - Print the
decimal_number
.
Note
I think you received 142857 which is called a cyclic number. Let me explain why:
142857 x 1 = 142857
142857 x 2 = 285714
142857 x 3 = 428571
142857 x 4 = 571428
142857 x 5 = 714285
142857 x 6 = 857142
. As you can recognize such multiplication results in a new number that is the same, but digits located in a different order; it creates a cycle. Another interesting fact for you🙄.
Thanks for your feedback!
Get Acquainted with the Octal Numeral System
There is another numeral system called octal. In comparison to binary or decimal, it consists of 8 digits, starting with zero: 0
,1
,2
,3
,4
,5
,6
,7
.
If you wonder why it was implemented, I want to clarify something.
Usage
As you remember the number in binary representation consists of several digits, one bite for each of them; but in an octal numeral system, three binary digits represent one octal. Therefore, you can represent one word for the computer using fewer symbols. Enormous strings of binary code can be represented in a more beautiful way for the computer; hence, less memory is filled. The principle of converting a number to the decimal system from octal one is the same as with binary:As you remember the number in binary representation consists of several digits, one bite for each of them; but in an octal numeral system, three binary digits represent one octal. Therefore, you can represent one word for the computer using fewer symbols. Enormous strings of binary code can be represented in a more beautiful way for the computer; hence, less memory is filled. The principle of converting a number to the decimal system from octal one is the same as with binary:
Rule
Algorithms of converting to decimal numeral system overlap for different numeral systems. Here is the same for octal number 221: the index of the left number 2 is 2, the index of the middle number 2 is 1 and the index of the number 1 is zero; but here we should multiply the numbers by 8 raised to the power of index. Hence, 221
-> 2*8^2
+2*8^1
+2*8^0
=128
+16
+2
=146
.
# Defining the octal number octal_number = 221 # Creating a variable for storing the converted decimal number decimal_number = 0 # The text should be realised here due to the reason that further the binary number will be changed print("The number in octal numeral system is: ", octal_number) # Creating value for working with the power of a number power = 0 # The loop executes till the number is not null while octal_number != 0: # Separating the last digit of octal_number using the remainder of the division operation last_digit = octal_number % 10 # Multiply last_digit by 8 raised to the relevant power result = last_digit * pow(8, power) # Adding the result to the decimal number decimal_number = decimal_number + result # This operation of integer division decreases a number and put aside the last digit that was already used octal_number = octal_number // 10 # Increasing iterator to work with the power power = power + 1 # Printing the result print("The number in decimal numeral system is: ", decimal_number)
Task
Doing as many tasks as possible is a recipe for success! Write the code that will decode the number 117 from the octal numeral system to decimal. Fill the gaps and follow the algorithm. If everything is correct you will receive one special number 🧐 But the explanation is waiting for you at the end of this chapter.
- Print the
octal_number
. - Define the loop which goes through the
octal_number
variable till it is zero. - Assign the remainder of division
octal_number
by10
to the variable last_digit. - Multiply the received
last_digit
by the8
raised to the relevant power. - Decrease the
octal_number
using integer division by10
. - Increase the
power
by1
. - Print the
decimal_number
.
Note
I think you received 142857 which is called a cyclic number. Let me explain why:
142857 x 1 = 142857
142857 x 2 = 285714
142857 x 3 = 428571
142857 x 4 = 571428
142857 x 5 = 714285
142857 x 6 = 857142
. As you can recognize such multiplication results in a new number that is the same, but digits located in a different order; it creates a cycle. Another interesting fact for you🙄.
Thanks for your feedback!
Get Acquainted with the Octal Numeral System
There is another numeral system called octal. In comparison to binary or decimal, it consists of 8 digits, starting with zero: 0
,1
,2
,3
,4
,5
,6
,7
.
If you wonder why it was implemented, I want to clarify something.
Usage
As you remember the number in binary representation consists of several digits, one bite for each of them; but in an octal numeral system, three binary digits represent one octal. Therefore, you can represent one word for the computer using fewer symbols. Enormous strings of binary code can be represented in a more beautiful way for the computer; hence, less memory is filled. The principle of converting a number to the decimal system from octal one is the same as with binary:As you remember the number in binary representation consists of several digits, one bite for each of them; but in an octal numeral system, three binary digits represent one octal. Therefore, you can represent one word for the computer using fewer symbols. Enormous strings of binary code can be represented in a more beautiful way for the computer; hence, less memory is filled. The principle of converting a number to the decimal system from octal one is the same as with binary:
Rule
Algorithms of converting to decimal numeral system overlap for different numeral systems. Here is the same for octal number 221: the index of the left number 2 is 2, the index of the middle number 2 is 1 and the index of the number 1 is zero; but here we should multiply the numbers by 8 raised to the power of index. Hence, 221
-> 2*8^2
+2*8^1
+2*8^0
=128
+16
+2
=146
.
# Defining the octal number octal_number = 221 # Creating a variable for storing the converted decimal number decimal_number = 0 # The text should be realised here due to the reason that further the binary number will be changed print("The number in octal numeral system is: ", octal_number) # Creating value for working with the power of a number power = 0 # The loop executes till the number is not null while octal_number != 0: # Separating the last digit of octal_number using the remainder of the division operation last_digit = octal_number % 10 # Multiply last_digit by 8 raised to the relevant power result = last_digit * pow(8, power) # Adding the result to the decimal number decimal_number = decimal_number + result # This operation of integer division decreases a number and put aside the last digit that was already used octal_number = octal_number // 10 # Increasing iterator to work with the power power = power + 1 # Printing the result print("The number in decimal numeral system is: ", decimal_number)
Task
Doing as many tasks as possible is a recipe for success! Write the code that will decode the number 117 from the octal numeral system to decimal. Fill the gaps and follow the algorithm. If everything is correct you will receive one special number 🧐 But the explanation is waiting for you at the end of this chapter.
- Print the
octal_number
. - Define the loop which goes through the
octal_number
variable till it is zero. - Assign the remainder of division
octal_number
by10
to the variable last_digit. - Multiply the received
last_digit
by the8
raised to the relevant power. - Decrease the
octal_number
using integer division by10
. - Increase the
power
by1
. - Print the
decimal_number
.
Note
I think you received 142857 which is called a cyclic number. Let me explain why:
142857 x 1 = 142857
142857 x 2 = 285714
142857 x 3 = 428571
142857 x 4 = 571428
142857 x 5 = 714285
142857 x 6 = 857142
. As you can recognize such multiplication results in a new number that is the same, but digits located in a different order; it creates a cycle. Another interesting fact for you🙄.
Thanks for your feedback!
There is another numeral system called octal. In comparison to binary or decimal, it consists of 8 digits, starting with zero: 0
,1
,2
,3
,4
,5
,6
,7
.
If you wonder why it was implemented, I want to clarify something.
Usage
As you remember the number in binary representation consists of several digits, one bite for each of them; but in an octal numeral system, three binary digits represent one octal. Therefore, you can represent one word for the computer using fewer symbols. Enormous strings of binary code can be represented in a more beautiful way for the computer; hence, less memory is filled. The principle of converting a number to the decimal system from octal one is the same as with binary:As you remember the number in binary representation consists of several digits, one bite for each of them; but in an octal numeral system, three binary digits represent one octal. Therefore, you can represent one word for the computer using fewer symbols. Enormous strings of binary code can be represented in a more beautiful way for the computer; hence, less memory is filled. The principle of converting a number to the decimal system from octal one is the same as with binary:
Rule
Algorithms of converting to decimal numeral system overlap for different numeral systems. Here is the same for octal number 221: the index of the left number 2 is 2, the index of the middle number 2 is 1 and the index of the number 1 is zero; but here we should multiply the numbers by 8 raised to the power of index. Hence, 221
-> 2*8^2
+2*8^1
+2*8^0
=128
+16
+2
=146
.
# Defining the octal number octal_number = 221 # Creating a variable for storing the converted decimal number decimal_number = 0 # The text should be realised here due to the reason that further the binary number will be changed print("The number in octal numeral system is: ", octal_number) # Creating value for working with the power of a number power = 0 # The loop executes till the number is not null while octal_number != 0: # Separating the last digit of octal_number using the remainder of the division operation last_digit = octal_number % 10 # Multiply last_digit by 8 raised to the relevant power result = last_digit * pow(8, power) # Adding the result to the decimal number decimal_number = decimal_number + result # This operation of integer division decreases a number and put aside the last digit that was already used octal_number = octal_number // 10 # Increasing iterator to work with the power power = power + 1 # Printing the result print("The number in decimal numeral system is: ", decimal_number)
Task
Doing as many tasks as possible is a recipe for success! Write the code that will decode the number 117 from the octal numeral system to decimal. Fill the gaps and follow the algorithm. If everything is correct you will receive one special number 🧐 But the explanation is waiting for you at the end of this chapter.
- Print the
octal_number
. - Define the loop which goes through the
octal_number
variable till it is zero. - Assign the remainder of division
octal_number
by10
to the variable last_digit. - Multiply the received
last_digit
by the8
raised to the relevant power. - Decrease the
octal_number
using integer division by10
. - Increase the
power
by1
. - Print the
decimal_number
.
Note
I think you received 142857 which is called a cyclic number. Let me explain why:
142857 x 1 = 142857
142857 x 2 = 285714
142857 x 3 = 428571
142857 x 4 = 571428
142857 x 5 = 714285
142857 x 6 = 857142
. As you can recognize such multiplication results in a new number that is the same, but digits located in a different order; it creates a cycle. Another interesting fact for you🙄.