In this tutorial, we will learn how to express integers in three different ways: decimal, octal, and hexadecimal. These are different systems we use to write numbers. Understanding these ways is important because we will be using them in the upcoming tutorials. So let’s get started and learn how to represent numbers in these different ways!
Decimal Number System
We all know about decimal numbers since we were kids. Decimal numbers are the numbers we use in our daily lives, like 45, 600, 88903, and so on. These numbers are made by multiplying each digit by 10 (which is the base of the decimal system) raised to the power of its position (also called place value), and then adding them together.
Note that the decimal number system is also called the base-10 number system and therefore, it uses a total of 10 digits from 0 to 9 to represent a number. Each digit in a number has a place value. The rightmost digit is the unit’s place, which has a place value of 0. As we move from right to left, each digit’s place value increases by 1.
For example, in the number 678, the place value of 8 is 0, the place value of 7 is 1, and the place value of 6 is 2. To get the number 678 from its digits, we multiply each digit by 10 raised to the power of its place value and then add them together:
By following this process, we can represent any decimal number using its digits.
Problem: Now, try using the same process to obtain the number 9872 from its digits.
Octal Number System
The octal number system is also known as the base-8 number system. It uses 8 digits from 0 to 7 to represent numbers. In the octal system, each digit is multiplied by 8 raised to the power of its place value to get the equivalent decimal number.
For example, let’s consider the octal number 75. To find its decimal equivalent, we multiply the digits by 8 raised to the power of their place values:
Therefore, the decimal equivalent of the octal number 75 is 61.
Note how we represent octal and decimal numbers by wrapping the numbers in parentheses and mentioning the base as the subscript.
Hexadecimal Number System
The hexadecimal number system is also called the base-16 number system. It uses a total of 16 digits: the first ten digits from 0 to 9 and the letters A, B, C, D, E, and F to represent the remaining digits. In the hexadecimal system, each digit is multiplied by 16 raised to the power of its place value to obtain the equivalent decimal number.
For example, let’s consider the hexadecimal number 1AF. To find its decimal equivalent, we multiply the digits by 16 raised to the power of their place values:
So, the decimal equivalent of the hexadecimal number 1AF is 431.
Summary
In this lesson, we covered the representation of numbers in different number systems. We started with the familiar decimal number system, where we multiply each digit by powers of 10 based on its position. Decimal numbers are commonly used in everyday life and are easy for humans to work with.
Then, we explored the octal number system, which uses a base of 8 and the digits 0 to 7. Each digit is multiplied by powers of 8 based on its position to obtain the equivalent decimal number. Octal numbers are often used in low-level programming.
Lastly, we looked at the hexadecimal number system, which uses a base of 16 and includes digits from 0 to 9 and letters A to F. Each digit is multiplied by powers of 16 based on its position to get the equivalent decimal number. Hexadecimal numbers are commonly used in computer programming, especially for representing binary data in a more compact and readable format.
Understanding these different number systems is important, as they have their own advantages and applications. Decimal numbers are widely used in everyday life, while octal and hexadecimal numbers are important in low-level programming and computer systems.
By learning about these number systems, we have gained valuable knowledge that will help us in future lessons and when working with different programming concepts.
Remember, decimal, octal, and hexadecimal number systems are just different ways of representing numbers, and each has its own significance and usefulness.
Leave a comment