Transcript Binary

Chapter 3
Number System and Codes
Decimal and Binary Numbers
Decimal and Binary Numbers
Converting Decimal to Binary
1. Sum of powers of 2
Converting Decimal to Binary
1. Repeated Division
Binary Numbers and Computers
Hexadecimal Numbers
Converting decimal to hexadecimal
Converting binary to hexadecimal
Converting hexadecimal to binary?
Hexadecimal numbers
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 positive numbers
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
Converting to decimal format
2’s Complement
 For negative numbers: Subtract the magnitude from 2n. Or
 Add 1 to the 1’s complement
Example
Convert to decimal value

Positive values:

0101 1001
= +89
Negative values
Two's Complement Arithmetic
Adding Positive Integers in 2's
Complement Form
Overflow in Binary Addition
Overflow in Binary Addition
Overflow in Binary Addition
Overflow in Binary Addition
Adding Positive and Negative
Integers in 2's Complement
Form
Adding Positive and Negative
Integers in 2's Complement
Form
Subtraction of Positive and Negative
Integers
Digital Codes

Binary Coded Decimal (BCD)
BCD
BCD
4221 Code
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
Binary –to-Gray Code Conversion
Gray –to-Binary Conversion
Gray –to-Binary Conversion
The Excess-3- Code
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:
11001
11110
Even Parity
110011
111100
11000
110000
Odd parity
110010
111101
110001