unit 3
play

Unit 3 Binary Representation ANALOG VS. DIGITAL 3.3 3.4 Analog - PowerPoint PPT Presentation

3.1 3.2 Unit 3 Binary Representation ANALOG VS. DIGITAL 3.3 3.4 Analog vs. Digital Analog vs. Digital The analog world is based on continuous Q. Which is better? events. Observations can take on (real) any A. Depends on what


  1. 3.1 3.2 Unit 3 Binary Representation ANALOG VS. DIGITAL 3.3 3.4 Analog vs. Digital Analog vs. Digital • The analog world is based on continuous • Q. Which is better? events. Observations can take on (real) any • A. Depends on what you are trying to do. value. • Some tasks are better handled with analog • The digital world is based on discrete events. data, others with digital data. Observations can only take on a finite number – Analog means continuous/real valued signals with of discrete values an infinite number of possible values – Digital signals are discrete [i.e. 1 of n values]

  2. 3.5 3.6 Analog vs. Digital Analog vs. Digital • How much money is in my checking account? • How much do you love me? – Analog: I love you with all my heart!!!! – Analog: Oh, some, but not too much. – Digital: 3.2 x 10 3 MegaHearts – Digital: $243.67 3.7 3.8 The Real (Analog) World Digital is About Numbers • The real world is inherently analog. • In a digital world, numbers are used to represent all the possible discrete events • To interface with it, our digital systems need – Numerical values to: – Computer instructions (ADD, SUB, BLE, …) – Convert analog signals to digital values (numbers) – Characters ('a', 'b', 'c', …) at the input. – Conditions (on, off, ready, paper jam, …) – Convert digital values to analog signals at the • Numbers allow for easy manipulation output. – Add, multiply, compare, store, … • Analog signals can come in many forms • Results are repeatable – Voltage, current, light, color, magnetic fields, – Each time we add the same two number we get pressure, temperature, acceleration, orientation the same result

  3. 3.9 3.10 Interpreting Binary Strings • Given a string of 1’s and 0’s, you need to know the representation system being used, before you can understand the value of those 1’s and 0’s. • ______________________________________ 01000001 = ? Unsigned DIGITAL REPRESENTATION Binary system ASCII BCD System system 65 10 ‘A’ ASCII 41 BCD 3.11 3.12 Binary Representation Systems • Codes • Integer Systems – Text – Unsigned • ASCII / Unicode • Unsigned (Normal) binary – Decimal Codes – Signed • Signed Magnitude • BCD (Binary Coded Decimal) / (8421 Code) • 2’s complement • Excess-N* • 1’s complement* • Floating Point OVERVIEW – For very large and small (fractional) numbers * = Not fully covered in this class

  4. 3.13 3.14 4 Skills • We will teach you 4 skills that you should know and be able to apply with confidence – Convert a number in any base (base r) to decimal (base 10) – Convert a decimal number (base 10) to binary Using positional weights/place values – Use the shortcut for conversion between binary BASE R TO BASE 10 (base 2) and hexadecimal (base 16) – Understand the finite number of combinations that can be made with n bits (binary digits) and its implication for codes including ASCII and Unicode 3.15 3.16 Number Systems Anatomy of a Decimal Number • Number systems consist of • A number consists of a string of explicit coefficients (digits). • Each coefficient has an implicit place value which is a _______ 1. ________________ of the base. 2. ___ coefficients [__________] • The value of a decimal number (a string of decimal • Human System: Decimal (Base 10): coefficients) is the sum of each coefficient times it place value 0,1,2,3,4,5,6,7,8,9 radix (base) • Computer System: Binary (Base 2): 0,1 (934) 10 = 9*___ + 3*___ + 4*____ = _____ • Human systems for working with computer systems (shorthand for human to read/write binary) Implicit place values Explicit coefficients – _____________________________________ (3.52) 10 = 3*____ + 5*____ + 2*____ = ____ – _____________________________________

  5. 3.17 3.18 Anatomy of a Binary Number General Conversion From Base r to Decimal • Same as decimal but now the coefficients • A number in base r has place values/weights are 1 and 0 and the place values are the that are the powers of the base powers of 2 • Denote the coefficients as: a i Most Significant Least Significant (a 3 a 2 a 1 a 0 .a -1 a -2 ) r = a 3 *r 3 + a 2 *r 2 + a 1 *r 1 + a 0 *r 0 + a -1 *r -1 + a -2 *r -2 Digit (MSB) Bit (LSB) (1011) 2 = 1*__ + 0*_ + 1*__ + 1*__ Right-most digit = Left-most digit = Least Significant Most Significant Digit (LSD) Digit (MSD) radix (base) place values coefficients = powers of 2 N r => _______=> D 10 Number in base r Decimal Equivalent 3.19 3.20 Examples Binary Examples (746) 8 = (1001.1) 2 = (10110001) 2 = (1A5) 16 = (AD2) 16 =

  6. 3.21 3.22 Powers of 2 Unique Combinations 2 0 = 1 • Given n digits of base r , how many unique numbers 2 1 = 2 can be formed? __ 2 2 = 4 2 3 = 8 – What is the range? [________] 2 4 = 16 2 5 = 32 2-digit, decimal numbers (r=10, n=2) 2 6 = 64 0-9 0-9 2 7 = 128 1024 512 256 128 64 32 16 8 4 2 1 3-digit, decimal numbers (r=10, n=3) 2 8 = 256 2 9 = 512 4-bit, binary numbers (r=2, n=4) 2 10 = 1024 0-1 0-1 0-1 0-1 6-bit, binary numbers (r=2, n=6) Main Point: Given n digits of base r, ___ unique numbers can be made with the range [________] 3.23 3.24 Approximating Large Powers of 2 • Often need to find decimal approximation of a large powers of 2 2 16 = 2 6 * 2 10 like 2 16 , 2 32 , etc. ≈ • Use following approximations: 2 24 = – 2 10 ≈ _________________ – 2 20 ≈ _________________ – 2 30 ≈ _________________ 2 28 = – 2 40 ≈ _________________ "Making change" • For other powers of 2, decompose BASE 10 TO BASE 2 OR BASE 16 into product of 2 10 or 2 20 or 2 30 and a 2 32 = power of 2 that is less than 2 10 – 16-bit half word: 64K numbers – 32-bit word: 4G numbers – 64-bit dword: 16 million trillion numbers

  7. 3.25 3.26 Decimal to Unsigned Binary Decimal to Unsigned Binary 73 10 = • To convert a decimal number, x, to binary: 128 64 32 16 8 4 2 1 – Only coefficients of 1 or 0. So simply find place values that add up to the desired values, starting with larger 87 10 = place values and proceeding to smaller values and place a 1 in those place values and 0 in all others 145 10 = 25 10 = 0.625 10 = 32 16 8 4 2 1 .5 .25 .125 .0625 .03125 3.27 3.28 Decimal to Another Base • To convert a decimal number, x, to base r: Use the place values of base r (powers of r). Starting – with largest place values, fill in coefficients that sum up to desired decimal value without going over. Shortcuts for Converting Binary (r=2), Hexadecimal (r=16) and Octal (r=8) SHORTHAND FOR BINARY 75 10 = hex 256 16 1

  8. 3.29 3.30 Binary, Octal, and Hexadecimal Binary to Octal or Hex • Make groups of 3 bits • Make groups of 4 bits • Octal (base 8 = 2 3 ) • Hex (base 16=2 4 ) starting from radix point starting from radix point • 1 Octal digit ( _ ) 8 can • 1 Hex digit ( _ ) 16 can and working outward and working outward represent: ________ represent: 0-F (_____) • Add 0’s where • Add 0’s where necessary necessary • 3 bits of binary (_ _ _) 2 • 4 bits of binary • Convert each group of 3 • Convert each group of 4 can represent: (_ _ _ _) 2 can represent: to an octal digit to an octal digit 000-111 = ________ 0000-1111= ______ • Conclusion… • Conclusion… 101001110.11 101001110.11 __Octal digit = __ bits __ Hex digit = ___ bits 3.31 3.32 Octal or Hex to Binary Hexadecimal Representation • Since values in modern computers are many bits, we • Expand each octal digit • Expand each hex digit use hexadecimal as a shorthand notation (4 bits = 1 to a group of 3 bits to a group of 4 bits hex digit) – 11010010 = D2 hex or 0xD2 if you write it in C/C++ 317.2 8 D93.8 16 – 0111011011001011 = 76CB hex or 0x76CB if you write it in C/C++

  9. 3.33 3.34 Binary Representation Systems • Integer Systems • Codes – Unsigned – Text • Unsigned (Normal) binary • ASCII / Unicode – Signed – Decimal Codes • Signed Magnitude • BCD (Binary Coded Decimal) • 2’s complement / (8421 Code) • 1’s complement* ASCII & Unicode • Excess-N* • Floating Point BINARY CODES – For very large and small (fractional) numbers * = Not covered in this class 3.35 3.36 Binary Codes BCD (If Time Permits) • Rather than convert a decimal number to binary which may lose some precision (i.e. 0.1 10 = infinite binary fraction), BCD • Using binary we can represent any kind of represents each decimal digit as a separate group of bits (exact information by coming up with a code decimal precision) • Using n bits we can represent 2 n distinct items – Each digits is represented as a ___________ number (using place values 8,4,2,1 for each dec. digit) – Often used in financial and other applications where decimal precision is needed (439) 10 Colors of the rainbow: Letters: This is the Binary Coded Decimal (BCD) •Red = 000 •‘A’ = 00000 representation of 439 •Orange = 001 •‘B’ = 00001 •Yellow = 010 •‘C’ = 00010 •Green = 100 . BCD Representation: •Blue = 101 . This is the binary •Purple = 111 . representation of 439 110110111 2 Unsigned Binary Rep.: •‘Z’ = 11001 (i.e. using power of 2 place values) Important: Some processors have specific instructions to operate on #’s represented in BCD

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend