Lecture 5
This presentation is the property of its rightful owner.
Sponsored Links
1 / 30

Lecture 5 PowerPoint PPT Presentation


  • 113 Views
  • Uploaded on
  • Presentation posted in: General

Lecture 5 . Topics. Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Numeric Values Representing Images Sec 1.6 Storing Integers Two’s Complement Notation Excess Notation. Representing Text.

Download Presentation

Lecture 5

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Lecture 5

Lecture 5


Topics

Topics

Sec 1.4 Representing Information as Bit Patterns

Representing Text

Representing Numeric Values

Representing Images

Sec 1.6 Storing Integers

Two’s Complement Notation

Excess Notation


Representing text

Representing Text

  • Each character (letter, punctuation, etc.) is assigned a unique bit pattern.

    • ASCII: Uses patterns of 7-bits to represent most symbols used in written English text

    • Unicode: Uses patterns of 16-bits to represent the major symbols used in languages world side

    • ISO standard: Uses patterns of 32-bits to represent most symbols used in languages world wide


Figure 1 12 the message hello in ascii

Figure 1.12 The message “Hello.” in ASCII


Representing numeric values

Representing Numeric Values

  • Binary notation: Uses bits to represent a number in base two

  • Limitations of computer representations of numeric values

    • Overflow – occurs when a value is too big to be represented

    • Truncation – occurs when a value cannot be represented accurately


Representing images

Representing Images

Resolutionrefers to the sharpness or clarity of an image

  • bitmaps that are divided into smaller pixels will yield higher resolution images

  • the left image is stored using 96 pixels per square inch, and the right image is stored using 48 pixels per square inch

    • the left image appears sharp, but has twice the storage requirements

  • Images are stored using a variety of formats and compression techniques

  • The simplest representation is a bitmap

  • Bitmaps partition an image into a grid of picture elements, called pixels, and then convert each pixel into a bit pattern


Storing integers

Storing Integers

  • Integers are categorized as:

    • Signed Integers

    • Unsigned Integers

    • Signed are those that include positive as well as negative numbers

    • While Unsigned are those that only represent positive numbers

    • The range for Signed Numbers is reduced to half


Signed integers

Signed Integers

There are two ways to represent Signed Integers:

Two’s complement notation: The most popular means of representing integer values

Excess notation: Another means of representing integer values

Both can suffer from overflow errors.


Representing negative numbers

Representing Negative Numbers

Can use “+” and “-”, as usual.

But requires extra symbols. How can we use bits instead?


Figure 1 21 two s complement notation systems

Figure 1.21 Two’s complement notation systems


Two s complement notation

Two’s complement Notation

Invert all bits, then add 1.


Two s complement it just works

Two’s complement – it just works!

0011(3 decimal)

+ 0010(2 decimal)

= (5 decimal ?)

0101

1101(-3 decimal)

+ 1110(-2 decimal)

= (-5 decimal ?)

11011

0011(3 decimal)

+ 1110(-2 decimal)

= (1 decimal ?)

10001


Problems with binary arithmetic

Problems with binary arithmetic

  • Fixed number of bits  can go out of range.

    0011 (3 decimal)

    + 0111(7 decimal)

    = 1010 (-6 decimal???)

  • Overflow: When result can’t be represented within range of bits.

    • Overflow occurs when the value that we compute cannot fit into the number of bits we have allocated for the result.

    • In addition, if operands have same sign and sum doesn’t.


Excess notation

Excess Notation

Excess 8 notation indicates that the value for zero is the bit pattern for 8, that is 1000

The bit patterns are 4 bits long

Positive numbers are above it in order and negative numbers are below it in order. 


Figure 1 24 an excess eight conversion table

Figure 1.24 An excess eight conversion table


Excess notation continue

Excess Notation (continue)

That is the zero point for Excess 128 notation is 128;  the zero point for excess 64 notation is 64; and so forth.

For example, let's say we want to determine the pattern for 15 in Excess 128 notation. 

The decimal number would be 128 + 15, or 143.  Therefore, the bit pattern would be 10001111. 


Storing fractions

Storing Fractions

In contrast to storage of Integers the storage of fractions requires not only the representation of the magnitude by the radix point as well

A popular way of doing this is based on scientific notation called Floating-Point Notation


Binary fractions revisited

Binary Fractions (revisited)

2-1 = 1/22-2 = 1/42-3 = 1/8

We use a radix point in the same role as the decimal point in decimal notation. That is, the digits to the left of the radix point represent the integer part of the value. The digits to the right represent the fractional part of the value.

_ _ _ . _ _ _

22 21 20 2-1 2-2 2-3

Example:

101.101 is 5 5/8 and 101.01011 is 5 11/32


Short cut bin decimal

Short Cut (Bin --- Decimal)

  • Binary-to-decimal for the part after the point

    • Convert binary digits as though there were no point.

    • Divide result by 2#bits – e.g., if 7 bits converted, then divide by 27 = 128.

  • E.g., .1101

    • 1101 = 13

    • So, .1101 = 13  24 = 13/16 = .8125


Figure 1 26 floating point notation components

Figure 1.26 Floating-point notation components


Look at scientific notation

Look at Scientific Notation

Let's look at some decimal numbers first, to get a feel for what needs to be done. First we need to know how many digits in the mantissa. Let's choose 5.

The last example shows us one of the problems with floating-point notation – truncation error. Part of the value being stored is lost because the mantissa field is not large enough.


Floating point notation

Floating Point Notation

Now let's switch to binary. Although a common standard uses 64 bits for a floating-point number: 1 bit for the sign, 11 bits for the exponent, and 52 bits for the mantissa, we will use an abbreviated version. Let's use one byte: 1 bit for the sign, 3 bits for the exponent, and 4 bits for the mantissa.


Lecture 5

The sign is easy enough 0 or 1.

The exponent has 3 bits and must be either + or -. We could use 2's complement, but excess notation is used instead! 3 bits means excess 4 notation. That leaves 4 bits for the mantissa. Why excess notation? It gives the best range of exponents and ease of wiring the circuitry.


Excess 4 notation

Excess 4 Notation

000  0 – 4 = -4001  1 – 4 = -3010  2 – 4 = -2011  3 – 4 = -1100  4 – 4 = 0101  5 – 4 = 1110  6 – 4 = 2111  7 – 4 = 3


How to convert

How to convert ??

Determine the sign bit

Convert the whole number to binary

Convert the fraction to binary

Move the radix to the left of the most significant digit (left-most non-zero digit)

Determine the exponent in excess 4 notation


Lecture 5

Example:

To store 1 1/8 we express it in binary notation and obtain 1.001

Copy the bit patterns into the mantissa field from left to right.


Example 1

Example 1

  • Examples:

  • +2 3/4

    • This is positive so our sign bit is 0

    • 2 is 10

    • 3/4 is .11

    • This gives us 10.11Move the radix two places to the left: .1011

    • So the exponent is +2: 110 in excess 4

    • Giving us: 0 110 1011


Example 2

Example 2

  • -1.1875

    • This is negative so our sign bit is 1

    • 1 is 1

    • .1875 is 3/16 giving us .0011

    • This gives us 1.0011: Because we have 4 bits we have to use 1.001: Move the radix one place to the left: .1001

    • So the exponent is +1: 101 in excess 4

    • Giving us: 1 101 1001


Example 3

Example 3

  • What is 10111100 in decimal?

    • Split it apart into its pieces: 1 011 1100

    • The sign is 1 or negative

    • The exponent is 011 or -1

    • The mantissa is 1100. Move the radix one place to the left: .01100 giving us 3/8

    • Our number is -3/8


  • Login