Binary Numbers - Discrete Mathematics - Lecture Slides, Slides of Discrete Mathematics

These lecture slides are very helpful for the student of discrete mathematics. The major points in these exam paper are: Binary Numbers, Number Systems, Gray Code, Negative Numbers, Residual Numbers, Coverage of Integer, Enumeration of Binary Numbers, Range of Representation, Equality of Addition, Variation of Binary Code

Typology: Slides

2012/2013

Uploaded on 04/23/2013

sarangapani
sarangapani 🇮🇳

4.5

(10)

62 documents

1 / 21

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSE20
Lecture 2: Number Systems: Binary
Numbers and Gray Code
1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download Binary Numbers - Discrete Mathematics - Lecture Slides and more Slides Discrete Mathematics in PDF only on Docsity!

CSE

Lecture 2: Number Systems: Binary Numbers and Gray Code 1

Number Systems

  1. Introduction
  2. Binary Numbers
  3. Gray code
  4. Negative Numbers
  5. Residual Numbers 2

2. Binary Numbers

  1. Definition (radix 2)
  2. Enumerations (value - > index)
  3. Addition (logic - > hardware) 4

2.1 Definition of Binary Numbers

  • Format: An n digit binary number (b n- 1 , …, b 1 , b 0

2 where b i in {0,1} for 0<= i < n

  • Value: b n- 1

n- 1

  • …+b 1

1 +b 0

0

  • Non-redundancy: The system is non- redundant, i.e. different binary numbers represent different values. 5

2.2 Enumeration of binary numbers

iCliker

When we enumerate binary numbers (b 3 b 2 b 1 b 0

2 from 0 to 15, the sequence of b 3 should be

  • A. 0101010101010101
  • B. 0011001100110011
  • C. 0000111100001111
  • D. 0000000011111111 7

2.3 Addition of Binary Numbers

Given two binary numbers A & B, we derive binary number S so that the value of S is equal to the sum of the values of A & B, i.e. (a n- 1 …,a 1 a 0

2 +(b n- 1 …b 1 b 0

2 =(s n- 1 …s 1 s 0

2 Caution: Overflow, i.e. the sum is beyond the range of the representation. 8

2.3 Addition of Binary Numbers

Equality of addition (a n- 1 …,a 1 a 0

2 +(b n- 1 …b 1 b 0

2 =(s n- 1 …s 1 s 0

2 That is to say a n- 1

n- 1 +…+a 1

1 +a 0

0 +b n- 1

n- 1 +…+b 1

1 +b 0

0 =(a n- 1 +b n- 1

n- 1 +…+(a 1 +b 1

1 +(a 0 +b 0

0 =s n- 1

n- 1 +…+s 1

1 +s 0

0 10

2.3 Addition of Binary Numbers

b 2 b 1 b 0 Value 0 0 0 0 0 0 1 1 0 1 0 2 0 1 1 3 1 0 0 4 1 0 1 5 1 1 0 6 1 1 1 7 8 4 2 1 0 0 1 1 0 1 0 1 8 4 2 1 0 0 1 1 0 1 1 0

Examples: 11

2.3 Adding 2 bits in a digit

a b (^) Carry Sum 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 0

Formula:

a+b=

2xCarry + Sum

13

2.3 Adding 3 bits in a digit

id a b c (^) Carry Sum 0 0 0 0 0 0 1 0 0 1 0 1 2 0 1 0 0 1 3 0 1 1 1 0 4 1 0 0 0 1 5 1 0 1 1 0 6 1 1 0 1 0 7 1 1 1 1 1 Formula: a+b+c= 2xCarry + Sum 14

3.1 Gray Code: Introduction

Gray: Frank Gray patented the code in 1947 A variation of binary code The code will be used for logic operation (CSE20, CSE140) Feature: only one bit changes for two consecutive numbers 16

3.2 Gray Code: Example

17 id b 2 b 1 b 0 g 2 g 1 g 0 0 000 000 1 001 001 2 010 011 3 011 010 4 100 110 5 101 111 6 110 101 7 111 100 id b 1 b 0 g 1 g 0 0 00 00 1 01 01 2 10 11 3 11 10 2 digits 3 digits Note the difference of the first and last rows.

3.2 Gray Code: iClicker

19 A 4-digit Gray code (g 3 g 2 g 1 g 0 ) at id=8 is written as (ref: previous page) A. (0101) B. (0110) C. (1100) D. None of the above

3.3 Gray Code: Construction

Construction of n-digit Gray code from n- 1 digit Gray code

  • Copy the n-1 digit Gray code for the top 2 n- 1 rows. Fill 0 at digit g n- 1 in the top rows.
  • Reflect and append the n-1 digit code for the bottom 2 n- 1 rows. Fill 1 at digit g n- 1 in the bottom rows. 20