What is binary? hexadecimal. Decimals are the counting method we usually use in our daily life.
Binary: 0 and 1, every two into one.
Octal: 0, 1, 2, 3, 4, 5, 6, 7, one for each octal.
Hexadecimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 1 for every 16.
In PLC, I, Q, M are octal, counters and timers are decimal.
Let’s talk about the conversion method between decimals first:
Binary to decimal:
One of the digits on the right side of binary is 2 to the power of 0, the second digit is 2 to the power of 1, and so on, the nth bit is 2 to the n-1 power. Then, after calculating and adding the bits to 1, it represents the decimal value:
Example: 2#11011=10#1+2+8+16=27
Decimal to binary
You can first remember some simple binary and decimal digital conversions.
For example: binary 1 1 1 1 1 1 1 1 1
decimal 512 256 128 64 32 16 8 4 2 1
Then: We give the number 68, then 68=64+4, all unnecessary digits are counted as 0, so:
8 is equal to: 2#1000100
Then octal and hexadecimal system can be converted to binary first, then binary to decimal, decimal can also be converted to binary first, then binary to octal and hexadecimal:
Hexadecimal to binary:
Each hexadecimal number represents a four-digit binary number. If there are not enough digits, add 0 to the left.
For example: 16 # f8d4f = 1118 = 0100d = 11014 = 0100
Then 16#F8D4 = 2#1111 0100 1011 0100
Octal to Binary:
Each octet represents a three-digit binary system, with 0s added to the left if there are not enough digits.
For example: 8#176 1=001 7=111 6=110
8#176=2#001 111 110
This knowledge is in our work We will often use it in , and we will keep in mind some common number system conversions. For conversions of some larger values, you can save time and use a calculator for the conversion.