L03 – Number Systems 8/31/2016 SESSION 3 – NUMBER SYSTEMS Reading: Chapter 2 (read 2.1-2.3) © Robert F. Kelly, 2012-2016 2 Reading • On-line tutorial (Modules I through III.b) http://courses.cs.vt.edu/~csonline/NumberSystems/Lessons/index.html • Exponents http://www.mathsisfun.com/exponent.html • Video – Binary Tutorial http://www.youtube.com/watch?v=0qjEkh3P9RE 1 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 3 Objectives • Review your knowledge of exponents • Understand the fundamentals of number systems • Learn to convert between various radix systems • Learn to add in binary • Become familiar with typical computer measures of space, time, and distance © Robert F. Kelly, 2012-2016 4 Exponent Basics • nm = n * n * n … (n multiplied by itself m times) • Example: 103 = 1000 or (10 * 10 * 10) • n1 = n • n0 = 1 • n-1 = 1/n • ni * nj = n(i+j) • ni / nj = n(i-j) 2 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 5 Transformations • Many times with computers we need to represent numbers and characters in a very specific way • To solve a problem, we often • Transform the human readable number or character to a computer representation • Solve the problem using the computer representation • Transform the computer representation of the answer back to a human readable representation © Robert F. Kelly, 2012-2016 6 Transformation Example Integer Arithmetic • What is 80 * 12? Exponent Representation • What is (5*24) * (3*22)? • = (5*24 * 3*22) Transform the problem to an exponent problem • = 15 * 24 * 22 • = 15 * (24+2) • = 15 * 26 • =15*64 = 960 Transform the answer to all integer 3 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 7 Which is Easier? • 65,536 / 32 = 2,048 or • 216 / 25 = 2(16-5) = 211 = 2,048 During the course you will begin to memorize some powers of 2 For example, 210 is 1024 Computers usually have only one way to do a calculation, so they must translate a number into their representation © Robert F. Kelly, 2012-2016 8 Small Numbers • We usually use negative exponents to represent very small numbers • .00001 = .1 * .1 * .1 * .1 * .1 = 10-5 = 10-1 * 10-1 * 10-1 * 10-1 * 10-1 = 10 (-1-1-1-1-1) = 10-5 We have lots of very small numbers when using computers (e.g., clock time of a computer 4 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 9 Measures of Computer Memory • A bit is the most basic unit of information in a computer • It is a state of “on” or “off” A byte is a group of eight bits. • A byte (8 bits) is the smallest possible addressable unit of computer storage • The term, “addressable,” means that a particular byte can be retrieved according to its location in memory Think of “addressable” in terms of a delivery person having an address of your home, but not each room in your home © Robert F. Kelly, 2012-2016 10 Introduction • A word is a contiguous group of bytes • Words can be any number of bits or bytes • Word sizes of 16, 32, or 64 bits are most common • In a word-addressable system, a word is the smallest addressable unit of storage • A group of four bits is called a nibble Most systems are byte addressable, not word addressable Word implications are primarily with alignment and path width (not very significant) 5 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 Positional Numbering Systems 11 Denotes the base • Our decimal system is the base-10 system. It uses powers of 10 for each position in a number • 40510 = 4*102 + 0*101 + 5*100 or 400 + 0 + 5 • Other number systems use a base other than 10 • 4058 = 4*82 + 0*81 + 5*80 = ? • Bytes store numbers using the position of each bit to represent a power of 2 • Example: 01110111 Base notation is sometimes omitted when it is obvious • The binary system is also called the base-2 system. • You can (easily?) convert a number in one system to a number in a different system © Robert F. Kelly, 2012-2016 12 Positional Numbering Examples • The decimal number 947 in powers of 10 is: 9 × 10 2 + 4 × 10 1 + 7 × 10 0 100=1, 101=10, 102=100, etc. This may seem obvious, but it helps to understand other number systems • The decimal number 5836.47 in powers of 10 is: 5 × 10 3 + 8 × 10 2 + 3 × 10 1 + 6 × 10 0 + 4 × 10 -1 + 7 × 10 -2 Note the representation of decimal numbers 6 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 13 Positional Numbering Systems • The binary number 110012 in powers of 2 is: 1 × 24+ 1 × 23 + 0 × 22 + 0 × 21 + 1 × 20 = 16 + 8 + 0 + 0 + 1 = 25 (base-10) Example of conversion of base 2 to base 10 • When the radix of a number is something other than 10, the base is denoted by a subscript. • Sometimes, the subscript 10 is added for clarification 110012 = 2510 © Robert F. Kelly, 2012-2016 14 Converting Between Bases • Binary numbers are the basis for all data representation in digital computer systems • You should become proficient with the base-2 system • Familiarity with base-2 enables you to understand • computer components • instruction set architectures • Every integer value can be represented exactly using any radix system 7 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 15 Converting • You will primarily convert base 2 numbers to base 10 – and the reverse You will also need to be familiar with base 16 (hexadecimal) as a convenient way to represent base 2 © Robert F. Kelly, 2012-2016 16 Converting Base 10 to Base 2 • Suppose we want to convert the decimal number 190 to base 2 • First look for the largest power of 2 that is less than or equal to the • • • • • • • target number (190) – in this case it is 128 (27) Therefore, the 7th bit in the binary number is 1 Compute the remainder (190-128 = 62) Repeat the process with the remainder, until the remainder is 0 190 = 27 + 62 The largest power of 2 less than 62 is 32 (25) Therefore, the 5th bit in the binary number is 1 remainder Partial result: 190=1*27+0*26+1*25+30 • Continue this process to determine that • 190 = 1*27+0*26+1*25+1*24+1*23+1*22+1*21+0*20 • 190 = 101111102 • 190 = 128 + 0 + 32 + 16 + 8 + 4 + 2 + 0 (base 10) 8 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 17 Converting Between Bases • Fractional values can be approximated in all base systems. • Unlike integer values, fractions do not necessarily have exact representations in all base systems • The quantity ½ is exactly representable in the binary and decimal systems, but is not in the ternary (base 3) numbering system. © Robert F. Kelly, 2012-2016 Counting Binary 0 1 10 11 100 101 110 111 1000 18 Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 ... 9 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 Class Questions 19 All questions refer to non-negative numbers • What is the smallest three digit decimal number? • What is the largest 3-digit decimal number? • What it the smallest 2-digit binary number • What is the largest 8 digit binary number (in binary and in decimal)? 0 or 000 999 0 11111111 255 © Robert F. Kelly, 2012-2016 20 Fractional Values • Fractional decimal values have nonzero digits to the right of the decimal point (e.g., .0123) • Fractional values of other radix systems have nonzero digits to the right of the radix point (e.g., .012) • Numerals to the right of a radix point represent negative powers of the radix: Radix point is the symbol that separates the integer part of a number from the fractional part 10-1 = 1/10 = .1 0.4710 = 4 × 10 -1 + 7 × 10 -2 0.112 = 1 × 2 -1 + 1 × 2 -2 = ½ + ¼ = 0.5 + 0.25 = 0.75 2-2 = 1/22 = ¼ = .2510 10 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 21 Addition in Binary Number System • Binary •0+0=0 •0+1=1 •1+0=1 • 1 + 1 = 10 (or 0 with a carry of 1) • Example: 0101 1000 1101 Check your work by converting to decimal: 5+8=13 and 13 in binary is 1101 © Robert F. Kelly, 2012-2016 22 Binary Addition With a Carry • 1 + 1 = 0 with a carry of 1 • Example: 1 0101 1001 1110 It’s a good idea to check your work by converting to decimal: 5+9=14 and 14 in binary is 1110 11 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 25 Converting Between Bases • It is difficult to read long strings of binary numbers • Even a modestly-sized decimal number becomes a very long binary number • For example: 110101000110112 = 1359510 • For compactness and ease of reading, binary values are usually expressed using the hexadecimal, or base-16, numbering system 116 = 110 … A16 = 1010 B16 = 1110 C16 = 1210 … © Robert F. Kelly, 2012-2016 Hexadecimal Conversion 26 116 = 110 … • The hexadecimal system uses numerals A16 = 1010 B16 = 1110 of C16 = 1210 D16 = 1310 E16 = 1410 F16 = 1510 0-9 and A-F • The decimal number 2610 is 1A16 • It is easy to convert between base 16 and base 2 because 16 = 24 • Thus, to convert from binary to hexadecimal, we group the binary digits into clusters of four digits 000110102 = 1A16 1 A 12 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 27 Hexadecimal Conversion • Using groups of hextets, the binary number 110101000110112 (= 1359510) in hexadecimal is: If the number of bits is not a multiple of 4, pad the left with zeros © Robert F. Kelly, 2012-2016 30 Measures of Capacity and Speed • Kilo- (K) = 1 thousand = 103 and 210 • Mega- (M) = 1 million = 106 and 220 • Giga- (G) = 1 billion = 109 and 230 • Tera- (T) = 1 trillion = 1012 and 240 • Peta- (P) = 1 quadrillion = 1015 and 250 • Exa- (E) = 1 quintillion = 1018 and 260 • Zetta- (Z) = 1 sextillion = 1021 and 270 What are 103 and 210 in decimal numbers? • Yotta- (Y) = 1 septillion = 1024 and 280 Whether a metric refers to a power of ten or a power of two typically depends upon what is being measured (e.g., money - power of 10, bits – power of 2 13 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 31 Examples of Download Speed • Pandora on the Web streams • 64Kbs-128Kbs – free listener • 192Kbs - Pandora • Netflix streams • SD – 3 Mbs • HD – 5 Mbs • Ultra HD – 25 Mbs More on screen resolution when we get to displays • Cablevision Ultra 50 = 50 Mbs (download) • Try out your download and upload speed • www.speedtest.net © Robert F. Kelly, 2012-2016 32 Units of Storage • Bit – an electronic component that has 2 states (usually represented as 0 and 1) • Byte – an addressable 8 bit sequence What does it mean to have “state”? Do we care how it is implemented in the computer? • Typical byte units • 1KB = 210 = 1,024 Bytes • 1MB = 220 = 1,048,576 Bytes • 1GB = 230 = 1,073,741,824 Bytes “B” denotes bytes and “b” denotes bits 14 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 33 Measures of Storage • Main memory (RAM) is measured in GB • Disk storage is measured in GB for small systems, TB (240) for large systems. • Examples • Flash drive – 8-128GB are typical • Data rate • USB 2.0 – 60 MBs • USB 3.0 – 625MBs or 5Gbs © Robert F. Kelly, 2012-2016 34 Fractional Measures • Milli- (m) = 1 thousandth = 10-3 • Micro- (μ) = 1 millionth = 10-6 • Nano- (n) = 1 billionth = 10-9 • Pico- (p) = 1 trillionth = 10-12 These symbols are important to remember • Femto- (f) = 1 quadrillionth = 10-15 • Atto- (a) = 1 quintillionth = 10-18 • Zepto- (z) = 1 sextillionth = 10-21 • Yocto- (y) = 1 septillionth = 10-24 15 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 35 Typical Units • Millisecond = 1 thousandth of a second • Hard disk drive access times are often 10 to 20 milliseconds. • Nanosecond = 1 billionth of a second • Main memory access times are often 50 to 70 nanoseconds. • Micron (micrometer) = 1 millionth of a meter • Circuits on computer chips are measured in microns. How many nanoseconds in a millisecond? 10-9 x ? = 10-3 © Robert F. Kelly, 2012-2016 36 Intuitive Measure of a Nanosecond • Light travels 11.8 inches in a nanosecond • The speed of an electron is close to, but less than the speed of light, so an electron travels no more than 11.8 inches in a second • Clock speeds are measured in nanoseconds, so this gives you a sense of the importance of packaging (smaller is faster) Speed of network travel is hugely important to high frequency traders (FT) 16 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 37 More Measures • Hertz = clock cycles per second (frequency) • 1MHz = 1,000,000Hz • Processor speeds are measured in MHz or GHz. Computer operations are controlled by a clock (like playing a musical instrument) © Robert F. Kelly, 2012-2016 38 Cycle Time • Note that cycle time is the reciprocal of clock frequency • A bus operating at 133MHz has a cycle time of about 7.52 nanoseconds: 133,000,000 cycles/second corresponds to 7.52ns/cycle or 133,000,000 cycles/second * 7.52 ns/cycle = 1,000,160,000 ns/second (a billion nanoseconds in a second) 17 L03 – Number Systems 8/31/2016 © Robert F. Kelly, 2012-2016 39 Have You Satisfied the Objectives? • Review exponents • Understand the fundamentals of number systems • Learn to convert between various radix systems • Learn to add in binary • Become familiar with typical computer measures of space, time, and distance 18
© Copyright 2025 Paperzz