Книга: Advanced PIC Microcontroller Projects in C
1.23 BCD Numbers
Разделы на этой странице:
1.23 BCD Numbers
BCD (binary coded decimal) numbers are usually used in display systems such as LCDs and 7-segment displays to show numeric values. In BCD, each digit is a 4-bit number from 0 to 9. As an example, Table 1.4 shows the BCD numbers between 0 and 20.
Table 1.4: BCD numbers between 0 and 20
Decimal | BCD | Binary |
---|---|---|
0 | 0000 | 0000 |
1 | 0001 | 0001 |
2 | 0010 | 0010 |
3 | 0011 | 0011 |
4 | 0100 | 0100 |
5 | 0101 | 0101 |
6 | 0110 | 0110 |
7 | 0111 | 0111 |
8 | 1000 | 1000 |
9 | 1001 | 1001 |
10 | 0001 0000 | 1010 |
11 | 0001 0001 | 1011 |
12 | 0001 0010 | 1100 |
13 | 0001 0011 | 1101 |
14 | 0001 0100 | 1110 |
15 | 0001 0101 | 1111 |
16 | 0001 0110 | 1 0000 |
17 | 0001 0111 | 1 0001 |
18 | 0001 1000 | 1 0010 |
19 | 0001 1001 | 1 0011 |
20 | 0010 0000 | 1 0100 |
Example 1.38
Write the decimal number 295 as a BCD number.
Solution 1.38
Write the 4-bit binary equivalent of each digit:
2 = 00102 9 = 10012 5 = 01012
The BCD number is 0010 1001 01012.
Example 1.39
Write the decimal equivalent of BCD number 1001 1001 0110 00012.
Solution 1.39
Writing the decimal equivalent of each group of 4-bit yields the decimal number: 9961
Оглавление статьи/книги
- 1.1 Introduction
- 1.2 Microcontroller Systems
- 1.3 Microcontroller Features
- 1.4 Microcontroller Architectures
- 1.5 Number Systems
- 1.6 Converting Binary Numbers into Decimal
- 1.7 Converting Decimal Numbers into Binary
- 1.8 Converting Binary Numbers into Hexadecimal
- 1.9 Converting Hexadecimal Numbers into Binary
- 1.10 Converting Hexadecimal Numbers into Decimal
- 1.11 Converting Decimal Numbers into Hexadecimal
- 1.12 Converting Octal Numbers into Decimal
- 1.13 Converting Decimal Numbers into Octal
- 1.14 Converting Octal Numbers into Binary
- 1.15 Converting Binary Numbers into Octal
- 1.16 Negative Numbers
- 1.17 Adding Binary Numbers
- 1.18 Subtracting Binary Numbers
- 1.19 Multiplication of Binary Numbers
- 1.20 Division of Binary Numbers
- 1.21 Floating Point Numbers
- 1.22 Converting a Floating Point Number into Decimal
- 1.23 BCD Numbers
- 1.24 Summary
- 1.25 Exercises
Похожие страницы
- 5.2.3. Действия с объектами Numbers
- Maintaining Accurate Serial Numbers
- Numbers
- 1.6 Converting Binary Numbers into Decimal
- 1.7 Converting Decimal Numbers into Binary
- 1.8 Converting Binary Numbers into Hexadecimal
- 1.9 Converting Hexadecimal Numbers into Binary
- 1.10 Converting Hexadecimal Numbers into Decimal
- 1.11 Converting Decimal Numbers into Hexadecimal
- 1.12 Converting Octal Numbers into Decimal
- 1.13 Converting Decimal Numbers into Octal
- 1.14 Converting Octal Numbers into Binary