CS%20101%20 - PowerPoint PPT Presentation

About This Presentation
Title:

CS%20101%20

Description:

Today: integers Unsigned Signed Later: text, images, code, etc. ... Information means that we are adding meaning to the data Binary is like the alphabet ... – PowerPoint PPT presentation

Number of Views:55
Avg rating:3.0/5.0
Slides: 14
Provided by: fur137
Learn more at: http://cs.furman.edu
Category:
Tags: adding | integers | point | power

less

Transcript and Presenter's Notes

Title: CS%20101%20


1
CS 101 Sept. 2
  • Chapter 3 data representation
  • Many kinds of data ? all in binary
  • Today integers
  • Unsigned
  • Signed
  • Later text, images, code, etc.

2
Different kinds of data!
Kind of data File type Software used
Numbers .xlsx .accdb Excel Access
Text .txt .docx .html NotePad MS Word Dreamweaver
Image .gif Photoshop
Instructions .exe The operating system
3
Converting to binary
  • A computer system has both HW SW
  • HW only understands binary
  • SW Translates human information into binary for
    the HW.
  • How?
  • Break into pieces (digits, words, letters,
    symbols, pixels, )
  • Each piece individually gets a binary number.

4
Data vs. information
  • What does 29613 mean to you? Or is it just a
    random number?
  • What might 111010110101110010 mean to the
    computer?
  • Information means that we are adding meaning to
    the data
  • Binary is like the alphabet all languages use it
    to give meaning to letters. What is pet set ?

5
Analog vs. Digital
  • Analog is how WE understand the world
  • Just warmer or crooked is enough for us
  • Can handle in between values
  • Think of a clock, speedometer, odometer
  • Digital emphasizes exact values, usually
    expressed as 0 or 1, true or false.
  • No such thing as in between. Its either 1030
    or 1031

6
An analogy
  • Think of the notes on a piano.
  • 88 keys
  • Range from lowest to highest key.
  • Granularity distance between consecutive notes.
  • But for computer, notes are converted to binary
    numbers!

7
Representations
  • To represent anything in binary, need to know
  • Number of bits? (size)
  • What do the bits mean? (scheme)
  • Representation schemes for integers
  • unsigned
  • signed
  • sign magnitude
  • BCD

8
Size of repn
  • Most often 8, 16, or 32 bits
  • For our examples, well use small sizes
  • 5 bits 25 different numbers
  • 32 bits 232 different numbers

9
Scheme I Unsigned
  • Ordinary binary number. ?
  • For 5 bits smallest 00000 (zero)
  • largest 11111 (31)
  • In general, smallest 0, largest 2n 1.
  • Going beyond possible range overflow

10
Scheme II Signed
  • Allows for negative numbers
  • We want half the repns to be negative.
  • Ex. 5 bits ? 32 numbers.
  • 16 numbers are negative
  • Thus, range is 16 to 15.
  • For n bits range is 2n1 to 2n 1 1

11
How to represent negatives
  • In unsigned, impossible!
  • In signed 3 steps to represent x
  • Find repn of x.
  • Invert the bits.
  • Add 1.
  • Try some examples.

12
Closer look at signed
  • In 5 bits largest number is 01111 (15)
  • lowest number is 10000 (16)
  • Leftmost bit is sign bit
  • Positive s have same repn as unsigned.
  • Technique for x doesnt work for 16.

13
Recap example
  • What does 110010 represent if interpreted as
  • 6 bit unsigned?
  • 6 bit signed?
Write a Comment
User Comments (0)
About PowerShow.com