1. About notion(base system)
Base system is a calculation
method that specifies the unit in which the number of digits changes when
counting.
For example, the normally used number is a decimal system using 10
digits from 0 to 9. In a day and night, time with 12 intervals is in the
decimal system, 1 hour has a period of 60 minutes, and 1 minute has a period of
60 seconds.
Unlike humans, in the case of computers, the only things recognized as
electronic products are that electricity flows (1) and does not flow (0), and
all operations are performed in binary format accordingly. However, the larger
the number, the longer it is difficult for humans to read, so it is common to
write binary numbers in hexadecimal format, where every four digits is converted
to a single number. Accordingly, it is necessary to know the number system for
three base systems, binary system, and hexadecimal system, and to be able to
convert between base systems.
Decimal - 010, 110,
210, 310, 410, 510, 610,
710, 810, 910 (10 digits, then continue in the order of 1010-1110-1210.)
The last 10 is added to distinguish it from binary and hexadecimal numbers, but
it is the same as the usual number.
Binary - 02, 12 (2 digits, then continue in the order of 102-112-1002.)
To distinguish binary numbers, ‘0b’ is sometimes written in front
like 0b100 instead of of the last 2.
Hexadecimal - 016,
116, 216, 316, 416, 516,
616, 716, 816, 916, A16,
B16, C16, D16, E16, F16 (16 digits, then continue in the order of 1016-1116-1216)
To distinguish hexadecimal numbers, ‘0x’ is sometimes written in front
like 0x12 instead of the last 16.
Comparing the table below:
Decimal |
010 |
110 |
210 |
310 |
410 |
510 |
610 |
710 |
Binary |
02 |
12 |
102 |
112 |
1002 |
1012 |
1102 |
1112 |
Hex |
016 |
116 |
216 |
316 |
416 |
516 |
616 |
716 |
Decimal |
810 |
910 |
1010 |
1110 |
1210 |
1310 |
1410 |
1510 |
Binary |
10002 |
10012 |
10102 |
10112 |
11002 |
11012 |
11102 |
11112 |
Hex |
816 |
916 |
A16 |
B16 |
C16 |
D16 |
E16 |
F16 |
Decimal |
1610 |
1710 |
1810 |
1910 |
2010 |
2110 |
2210 |
2310 |
Binary |
100002 |
100012 |
100102 |
100112 |
101002 |
101012 |
101102 |
101112 |
Hex |
1016 |
1116 |
1216 |
1316 |
1416 |
1516 |
1616 |
1716 |
2. Base Conversion - Decimal to Binary
Before the conversion, it should
be noted that the numbers in each base system are constructed as powers of the
base system as the digits are increased.
For example, the decimal number 12310 is expressed as (110×102)+(210×101)+(310×100). In the same way, the
binary number 101002 can be expressed as (12×24)+(02×23)+(12×22)+(02×22)+(02×20). It can be seen that
the table above is the same.
When converting a decimal number to a binary number, the method of
dividing 2 repeatedly is usually used. To convert 12310 to a binary
number, do as follows.
2 )123
2 ) 61······1
2 ) 30······1
2 ) 15······0
2 ) 7······1
2 ) 3······1
2 ) 1······1
0······1
After dividing by 2, write the remainder
on the right until the quotient becomes 0, and then write the recorded
remainders in order from the bottom to the result of converting to binary
number 11110112.
Another way to convert a decimal number to a binary number is to
subtract a power of 2, which is to subtract from the largest number that can be
subtracted. If it is 12310, subtraction is repeated starting from 6410, which is the
smallest and largest power, and if it can be subtracted, it is recorded as 1,
and if it cannot be subtracted, it is recorded as 0 and repeated until it
becomes 0.
12810 : Can't subtraction
6410 : 12310-6410=5910
3210 : 5910-3210=2710
1610 : 2710-1610=1110
810 : 1110-810=310
410 : Can't subtraction
210 : 310-210=110
110 : 110-110=010
12810 |
6410 |
3210 |
1610 |
810 |
410 |
210 |
110 |
0 |
1 |
1 |
1 |
1 |
0 |
1 |
1 |
As a result of the calculation, 11110112 is
the same.
Get used to either method, whichever way you are comfortable with.
3. Base Conversion - Binary to Decimal
If you understand the notation for powers of numbers, it's simple. If the binary number 110001102 is (12×27)+(12×26)+(02×25)+(02×24)+(02×23)+(12×22)+(12×22)+(02×20) and ends by adding only non-zero digits, 27+26+22+21. That is, 12810+6410+410+210=19810.
4. Base Conversion - Between Decimal and Hexadecimal
The same method can be used when
converting decimal number to binary number, but it is omitted because it is more
convenient to convert to binary number rather than double-digit division and
then convert again to hexadecimal number.
When converting a hexadecimal number to a decimal number, it can also be
used as a notation for power, but it is omitted because it is convenient to
calculate through binary numbers, while multiplication by two digits is often
inconvenient.
In conclusion, it is a conversion that can be done, but is not good.
5. Base Conversion - Between Binary and Hexadecimal
Between binary and hexadecimal,
there is a formula: ‘4 binary digits = 1 hexadecimal digit’. In fact, 24=16, so naturally, the process of
converting the number 11110112 is as follows.
First, cut off 4 digits from the 1's digit. That is, 111 and 1011
become 1112 and 10112.
Each of the four-digit numbers is converted to hexadecimal according to
the comparison table, and then written. It becomes 7B16.
|
1 |
1 |
1 |
1 |
0 |
1 |
1 |
7 |
B |
Converting hexadecimal to binary is also reversed. When converting hexadecimal number C616, convert C16 and 616 into 4-digit binary number and write it as it is. It becomes 110001102.
6 |
|||||||
1 |
1 |
0 |
0 |
0 |
1 |
1 |
0 |
Because the process is so simple, if you remember only 16 corresponding numbers, you can instantly convert from binary to hexadecimal and from hexadecimal to binary.
6. Conclusion
Just learn how to calculate this yourself, and usually use a calculator on your computer or a converter on the Internet.
No comments:
Post a Comment