400 likes | 565 Views
Chapter 3. Number System and Codes. Decimal and Binary Numbers. Decimal and Binary Numbers. Converting Decimal to Binary. Sum of powers of 2. Converting Decimal to Binary. Repeated Division. Binary Numbers and Computers. Hexadecimal Numbers. Converting decimal to hexadecimal.
E N D
Chapter 3 Number System and Codes
Converting Decimal to Binary • Sum of powers of 2
Converting Decimal to Binary • Repeated Division
Converting binary to hexadecimal Converting hexadecimal to binary?
Binary arithmetic • Binary addition
Representing Integers with binary • Some of challenges:- • Integers can be positive or negative • Each integer should have a unique representation • The addition and subtraction should be efficient.
Representing a negative numbers using Sign-Magnitude notation -5 = 1101 4-bits sign-manitude -55= 10110111 8-bits sign-magnitude
1’s Complement • The 1’s complement representation of the positive number is the same as sign-magnitude. • +84 = 01010100
1’s Complement • The 1’s complement representation of the negative number uses the following rule:- • Subtract the magnitude from 2n-1 • For example: • -36 = ??? • +36 = 0010 0100
1’s Complement • Example :- • - 57 • +57 = 0011 1001 • -57 = 1100 0110
2’s Complement • For negative numbers:- • Subtract the magnitude from 2n. Or • Add 1 to the 1’s complement
Convert to decimal value • Positive values:- • 0101 1001 = +89 • Negative values
Adding Positive Integers in 2's Complement Form Overflow in Binary Addition
Digital Codes • Binary Coded Decimal (BCD)
Gray Code • In pure binary coding or 8421 BCD then counting from 7 (0111) to 8 (1000) requires 4 bits to be changed simultaneously. • Gray coding avoids this since only one bit changes between subsequent numbers
Parity • The method of parity is widely used as a method of error detection. • Extar bit known as parity is added to data word • The new data word is then transmitted. • Two systems are used: • Even parity: the number of 1’s must be even. • Odd parity: the number of 1’s must be odd.
Parity • Example: