To program well, we need to know binary, decimal, and hexadecimal numbers. The following chart shows the relationships between these notations.
Decimal | Binary | Hexadecimal |
---|---|---|
0 | 0000 | 0 |
1 | 0001 | 1 |
2 | 0010 | 2 |
3 | 0011 | 3 |
4 | 0100 | 4 |
5 | 0101 | 5 |
6 | 0110 | 6 |
7 | 0111 | 7 |
8 | 1000 | 8 |
9 | 1001 | 9 |
10 | 1010 | A |
11 | 1011 | B |
12 | 1100 | C |
13 | 1101 | D |
14 | 1110 | E |
15 | 1111 | F |
In Cubloc’s Ladder Logic, we express binary and hexadecimal numbers in the following manner:
Binary: 00101010B Hexadecimal: 0ABCDH
We put a B at the end of the binary number and an H at the end for hexadecimal numbers. To clearly identify that a hexadecimal value is a number, we can put a 0 in front of the hexadecimal number. (E.g. : 0ABH, 0A1H, 0BCDH )
*BASIC is slightly different from Ladder Logic in the way binary and hexadecimal numbers are expressed. &B100010 is used for binary and &HAB is used for hexadecimal.