Representations - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Representations

Description:

Representations – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 15
Provided by: pagesSt
Category:

less

Transcript and Presenter's Notes

Title: Representations


1
Representations
  • Example Numbers
  • 145
  • CVL
  • 10010001
  • 91


2
Meaning of Number Representation
  • Examples
  • 145 1102 4101 5100 Decimal
  • CVL 100 5 50 Roman
  • 10010001127 124 120 Binary
  • 91 9161 1160
    Hexadecimal
  • 100 101010101111
    1

  • Egypt
  • 260 10105
    Babylon
  • 720 5
    Maya

3
Meaning of Numbers Convention/Agreement
  • Any number consists of symbols
  • The value of a number is defined by a set of
    rules of how to interpret these symbols
  • Most systems have a base number
  • 10 Decimal
  • 2 Binary
  • 8 Octal
  • 16 Hexadecimal

4
What makes a good representations?
  • Meet certain constraints on the symbols
  • Intuitive interpretation
  • Can express everything you need
  • !! Support for frequent operations
  • Efficiency
  • Space

5
What do we want to represent Data Types
  • Set of objects of the same kind
  • Defined by
  • a way of representing each object
  • a group of operations to perform on such objects
  • Basic data types of computer
  • integers (unsigned and signed)
  • plain text characters
  • bit vectors
  • (floating point numbers)

6
Computer Representation
  • Computer representation
  • Symbols 0,1
  • Words sequence of k symbols (bits)
  • 8 bit 1 byte
  • notation for an unknown k-bit word
  • ak-1a k-2 a1a0
  • ak-1is called the most significant bit
  • a0 is called the least significant bit
  • k is always a power of 2 16 or 32

7
Unsigned Integer Representation
  • 1451102 4101 5100 Decimal
  • 10010001ui Binary
  • 127 026025 124 023 022 021 120
  • 112806403211608040210
  • 145
  • Multiply and Add Algorithm

8
(No Transcript)
9
How good is unsigned integer?
  • Positive
  • Uses only 0 and 1
  • Easy addition and conversion to decimal
  • Negative
  • Limited size (2k) for k-bit word
  • No negative
  • Limited subtraction

10
Signed Integers
  • need to represent both non-negative and negative
    integers
  • need to be able to perform the following
    operations
  • addition (using the same rules as before)
  • negation
  • subtraction (trivial)
  • three different representations will be
    considered
  • in all three representations words whose most
    significant bit
  • is 0 represent the same non-negative integer

11
Signed Magnitude
  • Most significant bit determines whether the
    number is positive (ak-10, as before ) or
    negative (ak-11)
  • 1 1 1 0 0 k4
  • 1 1 1 0 (-6)
  • 0 1 1 1 (7)
  • 0 1 0 1 (5)
  • We now have negative numbers
  • Easy negation, only change first bit
  • -
  • Addition does not work anymore
  • Does not work!

12
Ones Compliment
  • Positive number as before
  • Negation is performed by inverting all bits
  • Example -6 Inverse (6)
  • Inverse (0110) 1001
  • test addition by adding 1001 with 0111
  • 1 1 1 1 0
  • 1 0 0 1 (-6)
  • 0 1 1 1 (7)
  • 0 0 0 0 (0)
  • Does not work!

13
Twos Compliment
  • Positive as before
  • Negation is performed by inverting all of the
    bits, and then adding 1 (binary)
  • -6 Inverse(6)0001 Inverse(0110)0001
  • 011000010111
  • test addition by adding 1010 with 0111
  • 1 1 1 0 0
  • 1 0 1 0 (-6)
  • 0 1 1 1 (7)
  • 0 0 0 1 (1)
  • Twos compliment is useful for representing
    signed integers

14
Things you should be able to do
  • Convert decimal number to binary and vice versa
    to all 4 forms of binary representation
  • Addition in unsigned integer
  • Addition and subtraction for twos complement
  • Negation in twos complement
  • Recognize the different subscripts ui, sm, 1c,2c
  • Understand why 2c is better than sm
  • Know which representation (of the 4) is used for
    integer
Write a Comment
User Comments (0)
About PowerShow.com