Docsity

Complements and Binary Arithmetic Operations, Summaries of Introduction to biology

Partial preview of the text

Download Complements and Binary Arithmetic Operations and more Summaries Introduction to biology in PDF only on Docsity!

Ministry of Higher Education Higher Technological Institute Computer Science Department Second level Course: - BSC 215 Lecturer: Dr. Ahmed Magdy Assistant teacher: Aya [email protected]

 COMPLEMENTS

▪ Complement is used in digital computer for simplifying the subtraction operation and for logic implementation. There are two types of complements 1 ) (b- 1 )’s complements 2 ) b’s complements

 (b-1)’S Complement:

▪ Given a number N on base b having n digits, the (b-1)’s

complement is defined as:

▪ For binary numbers b = 2 , and b- 1 = 1 ▪ The 1 ’s complement of a binary number is obtained by subtracting each digit of the given number from 1. However, the subtraction of binary digit from 1 causes the bit to change from 1 to 0 or from 0 to 1.

▪ For octal numbers: b = 8 , and b- 1 = 7 ▪ The 7 ’s complement of an octal number is obtained by subtracting each digit of the given number from 7.

 b’s Complement

▪ Given a number N on base b having n digits, the b’s complement is defined as: ▪ Comparing with (b- 1 )’s complement, we note that the b’s complement is obtained by adding 1 to the (b- 1 )’s complement

▪ For decimal numbers: b = 10

▪ Rules for obtaining 10’s complement:

  1. Leaving all least significant 0’s unchanged
  2. Subtracting the first nonzero least significant digit from 10
  3. Subtracting all higher digit from 9
  • ▪ For binary numbers b =
  • ▪ For octal numbers: b =
  • ▪ For hexadecimal numbers: b =

 The number in the computer system can be either signed or unsigned number.  Unsigned Number: ▪ The data format of 8 - bit unsigned number is shown in this figure. The 8 bits represents the magnitude of the number. ▪ For example the unsigned number ( 0 0 1 0 0 1 0 1 ) 2 is ( 37 ) 10

 Signed Number:

▪ The data format of 8 - bit signed number is shown in the

following figure. The left most bit (b 8 ) represents the sign of the

number, where the other 7 bits (b 7 to b 1 ) represent the

magnitude of the number.

▪ If b 8 = 0 it means that the number is positive and if b 8 = 1 it means that the number is negative and its magnitude is represented by 3 ways.

▪ Representation of negative number

▪ The negative number can represented in one of the following two systems

  1. Signed magnitude system
  2. Signed complement system (signed 1’s complement and signed 2’s complement)

 Binary Arithmetic Operations

▪ The binary arithmetic operations are:

a) Binary addition

b) Binary Subtraction

c) Binary shift

d) Binary multiplication

e) Binary division

a) Binary addition: