Since childhood, we have used the "decimal" system to represent numbers. This is the usual way of writing numbers, as we have only ten fingers. A certain number can be expressed by combining digits in their specific places. Looking closely, we can see that the base of this "representation" is always 10, which is another reason why this system is called decimal or "base 10".
As it turns out, several other number systems exist that allow us to present the same numbers in different ways. In the digital world, it is necessary to represent them in ways that facilitate computational processes. Here, the binary system helps, which uses only 0s and 1s. It is the basis of even very complex computer systems. We can say that the binary system is mainly used, making it the language of computers, basically :) Understanding binary and other number systems, such as decimal and hexadecimal, and learning to convert between them is crucial to computer science and programming.
In contrast to binary, there is another helpful system called hexadecimal (base 16), which simplifies binary representation by using 16 digits: the numbers 0-9 and the letters A-F. Each hexadecimal digit represents four binary digits, with each letter A-F representing numbers 10-15 respectively, making it convenient for representing large binary numbers.
To convert from binary to decimal, start by denoting the positions of the digits from right to left as 0, 1, 2, and so on. Multiply the rightmost digit by 2^0. For each digit to the left, increase the power of two by one until every digit in the binary number is multiplied. Then, calculate the sum of the products, which will give you the appropriate decimal number. For instance, let's take the binary number 1011 and converter it:
1×2^3 + 0×2^2 + 1×2^1 +1×2^0 = 8 + 0 + 2 + 1 = 11
So, the binary number 1011 is the decimal number 11.
Converting from decimal to binary is also simple. Repeatedly divide the decimal number by 2, noting the remainder after each operation until 0 is obtained. The binary representation is the sequence of remainders in reverse order. Let's take the decimal number 32 and convert to binary:
**32/2 = 16 (remainder = 0)
16/2 = 8 (remainder = 0)
8/2 = 4 (remainder = 0)
4/2 = 2 (remainder = 0)
2/2 = 1 (remainder = 0)
1 /2 = 0 (remainder = 1)
**So, the decimal number 36 is the binary number 100000.
Among the ways of converting binary form to hexadecimal and vice versa, the most straightforward is grouping. You can use this technic to go from base 2 to base 4 or other bases with any power of 2. For 16 hexadecimal digits representations, group 4 by 4. If the number is not the power of 2, I suggest changing it to base 10 and then what base you need. This is the simplest and fastest way.
Now, back to binary! As binary numbers have the same rights as decimal ones, we can perform arithmetic operations in binary similar to those in decimal. To do binary addition, remember these three rules:
- 0+0=0
- 0+1=1
- 1+1=10 (we write 0 and carry 1)
For example, find the sum of 1001 and 1100:
**1001
- 1100 = 10101 ** Convert the binary numbers into decimals to check your answer. In this case: 1001 = 9 1100 = 12 10101 = 21 9 + 12 = 21 is true, so 1011 + 1100 = 10111 is also true.
Binary subtraction:
- 1-1=0
- 0-0=0
- 0-1=1 (we need to borrow)
If the first number is smaller than the second, you may ask, what if the result is negative? For that case, there is Two's Compliment Method. To find the two's complement of a negative number, start by writing the positive version of that number. For instance, we want to find the two's complement of −0011. First, write positive version- 0011 and then invert all the bits by changing 0s to 1s and 1s to 0s. So, 0011 becomes1100. After that, add 1 to the inverted number, which gives us 1101. Easy right?
Multiplication and Division are the last operations to cover today. To multiply binary numbers, firstly, the rightmost digit in the multiplier is multiplied with each digit in the multiplicand, then the next digit to the left and so on, until the leftmost digit in the multiplier is reached. To obtain the final answer, add results together.
1011×111=100001
The binary Division follows the same rules as long Division in decimal numbers, though it is simplified because the quotient can only be 0 or 1.
Now you know that besides usual decimal numbers, systems like Binary and Hexadecimal numbers exist, offering an efficient way for computers to perform operations. Remember to practice arithmetic operations on your own to understand it better! Remember, these concepts may be simple but serve as the foundation for understanding how computers process data.
Karine Papoyan
Top comments (0)