160 likes | 219 Views
Harvard University CSCI E-2a Life, Liberty, and Happiness After the Digital Explosion. 3B: Representation. Binary counting 1+1=10, or 1+1=0 and carry 1. Positive and Negative Numbers. Signed and unsigned numbers Unsigned: 2 8 =256 bit patterns represent 0 … 255
E N D
Harvard UniversityCSCI E-2aLife, Liberty, and HappinessAfter the Digital Explosion 3B: Representation
Positive and Negative Numbers • Signed and unsigned numbers • Unsigned: 28=256 bit patterns represent 0 … 255 • Signed: 28 bit patterns represent -128 … +127 • Leftmost bit = sign bit: 0 => 0 or pos, 1 => neg • Largest 8-bit positive number = 01111111 = 127 • 0 = 00000000 • Most negative negative number = 10000000 =-128
Negative numbers -1 = 11111111so addition works the same for positive and negative numbers
Biggest Numbers • Biggest positive number = 01111111 (like 999999 on a car odometer) • Most negative negative number = 10000000
Biggest Positive Number + 1 “=”Most Negative Negative Number
The Comair Christmas “Glitch” • 16 bits for monthly count of crew changes • Biggest positive 16-bit number =32,767 • December was a bad month, lots of snowstorms, lots of flights rescheduled • As Christmas approached the count went from 32,767 to -32,768 by adding 1
Bytes • 1 byte = 8 bits = 2 hex digits = 1 character • 210 =1024 bytes = 1 kilobyte = 1KB • 220 =1,048,576 bytes = 1 megabyte = 1MB • 230 bytes = 1 gigabyte = 1GB = “a billion” • 240 bytes = 1 terabyte = 1TB = “a trillion” • 250 bytes = 1 petabyte = 1PB = “a quadrillion” • 260 bytes = 1 exabyte = 1EB = a quintillion bytes • 270 = zetta • 280 = yotta
K • All this terminology based on the accident that • Which is 1K? • There are new standard names: • 1 kibibyte = 1000 bytes • vs. 1 kilobyte = 1024 bytes • But almost no one uses “kibi-”, “mebi-”, etc.
http://www.ccc.de/congress/2004/fahrplan/files/316-hidden-data-slides.pdfhttp://www.ccc.de/congress/2004/fahrplan/files/316-hidden-data-slides.pdf