Download presentation
Presentation is loading. Please wait.
Published byMarlene Berry Modified over 9 years ago
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 dataFile typeSoftware used Numbers.xlsx.accdb Excel Access Text.txt.docx.html NotePad MS Word Dreamweaver Image.gifPhotoshop Instructions.exeThe 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.” It’s either 10:30 or 10:31…
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 rep’n Most often 8, 16, or 32 bits For our examples, we’ll use small sizes 5 bits: 2 5 different numbers 32 bits: 2 32 different numbers
9
Scheme I: Unsigned Ordinary binary number. For 5 bits: smallest = 00000 (zero) largest = 11111 (31) In general, smallest = 0, largest = 2 n – 1. Going beyond possible range: “overflow”
10
Scheme II: Signed Allows for negative numbers We want half the rep’ns to be negative. Ex. 5 bits 32 numbers. –16 numbers are negative –Thus, range is –16 to +15. For n bits: range is –2 n–1 to 2 n – 1 – 1
11
How to represent negatives In unsigned, impossible! In signed: 3 steps to represent –x: –Find rep’n 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 rep’n as unsigned. Technique for –x doesn’t work for –16.
13
Recap example What does 110010 represent if interpreted as: –6 bit unsigned? –6 bit signed?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.