# 3

# Digital Arithmetic

Having discussed different methods of numeric and alphanumeric data representation in the first two chapters, the next obvious step is to study the rules of data manipulation. Two types of operation that are performed on binary data include arithmetic and logic operations. Basic arithmetic operations include addition, subtraction, multiplication and division. AND, OR and NOT are the basic logic functions. While the rules of arithmetic operations are covered in the present chapter, those related to logic operations will be discussed in the next chapter.

## 3.1 Basic Rules of Binary Addition and Subtraction

The basic principles of binary addition and subtraction are similar to what we all know so well in the case of the decimal number system. In the case of addition, adding ‘0’ to a certain digit produces the same digit as the sum, and, when we add ‘1’ to a certain digit or number in the decimal number system, the result is the next higher digit or number, as the case may be. For example,6 + 1 in decimal equals ‘7’ because ‘7’ immediately follows ‘6’ in the decimal number system. Also, 7 + 1 in octal equals ‘10’ as, in the octal number system, the next adjacent higher number after ‘7’ is ‘10’. Similarly, 9 + 1inthe hexadecimal number system is ‘A’. With this background, we can write the basic rules of binary addition as follows:

- 0 + 0 = 0.
- 0 + 1 = 1.
- 1 + 0 = 1.
- 1 + 1 = 0 with a carry of ‘1’ to the next more significant bit.
- 1 + 1 + 1 = 1 with a carry of ‘1’ to ...