220 likes | 385 Views
LSP 121. The Power of Numbers. Conversions. Convert 23 feet to inches We all know there are 12 inches to a foot, so 12 * 23 = 276 inches But what did we really do?. 12 inches. 23 feet x. 1 foot. Conversions.
E N D
LSP 121 The Power of Numbers
Conversions • Convert 23 feet to inches • We all know there are 12 inches to a foot, so 12 * 23 = 276 inches • But what did we really do? 12 inches 23 feet x 1 foot
Conversions • At a French department store, the price for a pair of Levi jeans is 45 euros. What is that in U.S. dollars? $1.37 45 euros x = $61.65 1 euro
Chain of Conversions • How many seconds in one day? 24 hours 60 min 60 sec 1 day x x x = 86,400 sec 1 day 1 hour 1 min
Chain of Conversions • You try this one: How many seconds in one year? • Here is another: Convert 8.3 miles per second to kilometers per hour (1 kilometer = 0.6214 miles)
Binary Numbers • Why should anyone learn binary? • All music, video, data, and computer programs are stored in computer memory/storage • Computers are based on the binary number system (a memory location is on/off, or 1/0) • If your iPod / computer / flash drive has 4GB storage capacity, what does that mean? • So you can buy the following awesome! clock:
Binary Numbers • Before we discuss binary numbers, do you really understand decimal numbers? There are 10 digits (0-9) so the base is 10 1024 = 1 x 103 + 0 x 102 + 2 x 101 + 4 x 100 • Binary numbers are similar, except there are only 2 digits (0 and 1), so the base is 2 10010 = 1 x 24 + 0 x 23 + 0 x 22 + 1 x 21 + 0 x 20
Binary Numbers • Let’s play a game. You are a cashier at your favorite store. How do you make $0.86 in change? • What if you only have dimes, nickels and pennies? • A good cashier always tries to use the biggest coins possible.
Binary Numbers • You are now working in a foreign country. They don’t have quarters, dimes, or nickels; they have 16 cent pieces, 8 cent pieces, 4 cent pieces, 2 cent pieces, and pennies, and you can only give out at most one of each coin! • How do you make change for $0.14? $0.29? • Let’s list these coins in order from highest on the left to lowest on the right.
Binary Numbers • What is the decimal value of binary 10010101? • What is the binary value of decimal 83? • Can we use a calculator to do binary conversions? • Go back and read the red clock (first lit row is hours, second row minutes, third row seconds)
Binary Arithmetic • Let’s add the following two binary values 10011100 01011010 • When a computer does arithmetic, it converts all values to binary. • This takes a little bit of time, which is why we say “if you aren’t doing arithmetic with the data, don’t declare it as type numeric”
Binary Representation • When you type the letter “n” on the keyboard, it converts it to a 7-bit binary value, based on the ASCII character set. (Need an ASCII chart? Google ASCII) • Thus, all Word documents are stored sequences of 7-bit ASCII characters (called bytes) • All color images are composed of teeny-tiny dots (pixels). Each pixel is composed of so much red, so much green, and so much blue (RGB)
Binary Representation • Music on iPods and such are stored in binary • music is an analog waveform • the waveform is sampled at regular intervals • each sample is converted to a binary value (such as 8-bits) • the binary values are stored in memory • Talking on a cellphone is also binary • all voice is converted to binary in the same way that music is converted to binary
Binary Representation • Is there any major at DePaul that does not use computers (or binary numbers)? • Do you want to apply for a job after graduation knowing that you might be competing with someone that understands the technology and the underlying binary system?
Back to Chain of Conversions • To connect a computer to the Internet, the computer needs an IP address. Currently IP addresses are 32 bits in length. How many addresses is that? There are 32 digits in an IP address. Each digit can be 0 or 1. So that’s 2 possible values per digit. How many possible outcomes? 2 x 2 x 2 x 2 x …. 32 times, OR Raise 2 to the 32nd power Or 232 = 4,294,967,296
Chain of Conversions • If they assign 1000 addresses a day, how long would those addresses last (in years)? 232 addresses x 1 day/1000 addresses = 4,294,967.296 days 4,294,967.296 days * 1 year/365 days = 11767.03 years Be careful! Don’t do: 232 addresses x 1000 addresses/1 day The term addresses won’t cancel!
Standardized Units Weights Grain (0.0648 gram) Ounce Pound Ton Long ton (2240 pounds) • In the U.S., we still use: Lengths Inch Foot Yard Rod (5.5 yards) Fathom (6 feet) Furlong (1/8 mile) Mile Nautical mile (6076.1 feet) Liquid measures Teaspoon Tablespoon (3 t) Fluid ounce (2 T) Cup (8 fluid ounces) Pint (16 fluid ounces) Quart (2 pints) Gallon (4 quarts) Barrel of petroleum (42 gals) Dry measures Dry pint Dry quart Peck (8 dry quarts) Bushel (4 pecks) Cord (128 cubic feet) Classic College of Engineering “expression”: Units of measure will always be stated in least likely terms. Example: Furlongs per fortnight.
Standardized Units • Most of the rest of the world uses the metric system: Small Values deci d 10-1 one-tenth centi c 10-2 one-hundredth milli m 10-3 one-thousandth micro µ 10-6 one-millionth nano n 10-9 one-billionth pico p 10-12 one-trillionth meter – length gram – mass second – time liter - volume Note: 2.3E+06 = 2.3 x 106 4.6E-04 = 0.00046 Large Values deca da 101 (ten) hecto h 102 (hundred) kilo k 103 (thousand) (such as 200 kbps transfer speed) mega M 106 (million) giga G 109 (billion) tera T 1012 (trillion) unless………………..
Standardized Units? • What about computer memory? • Note: memory is based on binary so we use base 2 K = kilo (kiloBytes or kilobits) = 210 = 1024 M = mega (megaBytes or megabits) = 220 = 1,048,576 G = giga (gigaBytes or gigabits) = 230 = 1,073,741,824 T = tera (teraBytes or terabits) = 240 = 1,099,511,627,776 followed by peta, exa, zetta, yotta • Some groups suggested we should call these kibi, mebi, gibi, tebi, pebi, exbi (and yes, zebi and yobi)
Logs • What is the log10(100)? • What is the log(1000)? (no subscript? assume 10) • 10 to what power = 1000? • Or 10P = 1000 • So if you say P = log(1000), the “opposite” is 10P = 1000 • What is the log(250)?
More Logs • What is the log2(4)? • 2 to what power = 4? (2P = 4) • What is the log2(32)? • What is the log2(1024)? • What is the log2(1000)? • Want precise answer? Take log(1000)/0.301