Книга: Advanced PIC Microcontroller Projects in C
1.17 Adding Binary Numbers
Разделы на этой странице:
1.17 Adding Binary Numbers
The addition of binary numbers is similar to the addition of decimal numbers. Numbers in each column are added together with a possible carry from a previous column. The primitive addition operations are:
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 10 generate a carry bit
1 + 1 + 1 = 11 generate a carry bit
Some examples follow.
Example 1.24
Find the sum of binary numbers 011 and 110.
Solution 1.24
We can add these numbers as in the addition of decimal numbers:
011
First column: 1 + 0 + 1
+ 110
Second column: 1 + 1 = 0 and a carry bit
-–––
Third column: 1 + 1 = 10
1001
Example 1.25
Find the sum of binary numbers 01000011 and 00100010.
Solution 1.25
We can add these numbers as in the addition of decimal numbers:
01000011
First column: 1 + 0 + 1
+ 00100010
Second column: 1 + 1 = 10
––––––––
Third column: 0 + carry = 1
01100101
Fourth column: 0 + 0 = 0
Fifth column: 0 + 0 = 0
Sixth column: 0 + 1 = 1
Seventh column: 1 + 0 = 1
Eighth column: 0 + 0 = 0
- 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
- 1.6 Converting Binary Numbers into Decimal
- 1.7 Converting Decimal Numbers into Binary
- 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.18 Subtracting Binary Numbers
- 1.19 Multiplication of Binary Numbers