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 Q. Which is better? continuous events. A. Depends on what you are trying to do. Observations


  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 • Q. Which is better? continuous events. • A. Depends on what you are trying to do. Observations can take on (real) any value. • Some tasks are better handled with analog data, others with digital data. • The digital world is based on – Analog means continuous/real valued signals with discrete events. Observations an infinite number of possible values can only take on a finite – Digital signals are discrete [i.e. 1 of n values] number of discrete 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 (i.e. ______ possibilities) • To interface with it, our digital systems need – Numerical values (5.7, 1923.8, …) 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) – Understand the finite number of combinations Using positional weights/place values that can be made with n bits (binary digits) and its BASE R TO BASE 10 implication for codes including ASCII and Unicode – Convert a decimal number (base 10) to binary – Use the shortcut for conversion between binary (base 2) and hexadecimal (base 16) 3.15 3.16 Number Systems Skill 1: Converting Base r to Decimal • Number systems consist of • 934.7 10 = 9 3 4 . 7 = 1. ________________ 2. ___ coefficients [__________] • Human System: Decimal (Base 10): • 1101.1 2 = 1 1 0 1 . 1 = 0,1,2,3,4,5,6,7,8,9 • Computer System: Binary (Base 2): 0,1 • 3B.4 2 = 3 B . 4 = • Human systems for working with computer systems (shorthand for human to read/write binary) – _____________________________________ – _____________________________________ Main Point : To convert any base to decimal (base 10), apply the implicit place values (weights) which are just the powers of the base and sum each digit times its place value.

  5. 3.17 3.18 Examples General Conversion From Base r to Decimal • A number in base r has place values/weights (746) 8 = that are the powers of the base • Denote the coefficients as: a i Generalized approach: (1A5) 16 = (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 Right-most digit = Left-most digit = Least Significant Most Significant Digit (LSD) Digit (MSD) Example: (AD2) 16 = (1001.01) r = 1*2 3 + 0*2 2 + 0*2 1 + 1*2 0 + 0*2 -1 + 1*2 -2 N r => _______=> D 10 Decimal Equivalent Number in base r 3.19 3.20 Binary Examples Powers of 2 • It helps to memorize the first 11 powers of 2 (1001.1) 2 = 2 0 = 1 2 1 = 2 2 2 = 4 2 3 = 8 2 4 = 16 (10110001) 2 = 1024 512 256 128 64 32 16 8 4 2 1 2 5 = 32 2 6 = 64 2 7 = 128 2 8 = 256 2 9 = 512 2 10 = 1024

  6. 3.21 3.22 Skill 2: Unique Combinations Approximating Large Powers of 2 • Often need to find decimal • Given n digits of base r , how many unique numbers can be approximation of a large powers of 2 formed? __ What is their range? [__________] 2 16 = 2 6 * 2 10 like 2 16 , 2 32 , etc. ≈ • Use the examples below to generalize the relationship: • Use following approximations: – 2 10 ≈ _________________ 2 24 = 2-digit, decimal numbers (r=10, n=2) – 2 20 ≈ _________________ 0-9 0-9 – 2 30 ≈ _________________ 3-digit, decimal numbers (r=10, n=3) 2 28 = – 2 40 ≈ _________________ • For other powers of 2, decompose 4-bit, binary numbers (r=2, n=4) into product of 2 10 or 2 20 or 2 30 and a 0-1 0-1 0-1 0-1 2 32 = power of 2 that is less than 2 10 6-bit, binary numbers (r=2, n=6) – 16-bit half word: 64K numbers Main Point: Given n digits of base r, ___ unique numbers – 32-bit word: 4G numbers can be made with the range [________] – 64-bit dword: 16 million trillion numbers 3.23 3.24 Skill 3: Decimal to Base r To convert a decimal number, x, to binary: • – Only coefficients of 1 or 0. So simply find place values that add up to the desired values, starting with larger place values and proceeding to smaller values and place a 1 in those place values and 0 in all others Similar to how one would _____________________ – "Making change" BASE 10 TO BASE 2 OR BASE 16 25 10 = 32 16 8 4 2 1

  7. 3.25 3.26 Decimal to Unsigned Binary Decimal to Another Base 73 10 = • To convert a decimal number, x, to base r: 128 64 32 16 8 4 2 1 – Use the place values of base r (powers of r). Starting 87 10 = with largest place values, fill in coefficients that sum up to desired decimal value without going over. 145 10 = 75 10 = hex 0.625 10 = 256 16 1 .5 .25 .125 .0625 .03125 3.27 3.28 Binary, Octal, and Hexadecimal • Octal (base 8 = 2 3 ) • Hex (base 16=2 4 ) • 1 Octal digit ( _ ) 8 can • 1 Hex digit ( _ ) 16 can represent: ________ represent: 0-F (_____) • 3 bits of binary (_ _ _) 2 • 4 bits of binary can represent: (_ _ _ _) 2 can represent: 000-111 = ________ 0000-1111= ______ Shortcuts for Converting Binary (r=2), Hexadecimal (r=16) and Octal (r=8) • Conclusion… • Conclusion… SHORTHAND FOR BINARY __Octal digit = __ bits __ Hex digit = ___ bits

  8. 3.29 3.30 Skill 4: Binary to Octal or Hex Octal or Hex to Binary • Make groups of 3 bits • Make groups of 4 bits • Expand each octal digit • Expand each hex digit starting from radix point starting from radix point to a group of 3 bits to a group of 4 bits and working outward and working outward • Add 0’s where • Add 0’s where necessary necessary 317.2 8 D93.8 16 • Convert each group of 3 • Convert each group of 4 4 2 1 4 2 1 4 2 1 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1 to an octal digit to an octal digit 101001110.11 101001110.11 4 2 1 8 4 2 1 4 2 1 4 2 1 8 4 2 1 3.31 3.32 Hexadecimal Representation • Since values in modern computers are many bits, we use hexadecimal as a shorthand notation (4 bits = 1 hex digit) – 11010010 = D2 hex or 0xD2 if you write it in C/C++ – 0111011011001011 = 76CB hex or 0x76CB if you write it in C/C++ ASCII & Unicode BINARY CODES

  9. 3.33 3.34 Binary Representation Systems Binary Codes • Integer Systems • Codes • Using binary we can represent any kind of – Unsigned – Text information by coming up with a code • Unsigned (Normal) binary • ASCII / Unicode • Using n bits we can represent 2 n distinct items – Signed – Decimal Codes • Signed Magnitude • BCD (Binary Coded Decimal) • 2’s complement / (8421 Code) • 1’s complement* Colors of the rainbow: Letters: • Excess-N* •Red = 000 •‘A’ = 00000 •Orange = 001 •‘B’ = 00001 • Floating Point* •Yellow = 010 •‘C’ = 00010 •Green = 100 . – For very large and small •Blue = 101 . (fractional) numbers •Purple = 111 . •‘Z’ = 11001 * = Not covered in this class 3.35 3.36 BCD (If Time Permits) ASCII Code • Used for representing text characters • Rather than convert a decimal number to binary which may lose some precision (i.e. 0.1 10 = infinite binary fraction), BCD • Originally 7-bits but usually stored as 8-bits = 1- represents each decimal digit as a separate group of bits (exact byte in a computer decimal precision) – Each digits is represented as a ___________ number (using place values 8,4,2,1 • Example: for each dec. digit) – Often used in financial and other applications where decimal precision is needed – "Hello\n"; (439) 10 – Each character is converted to ASCII equivalent This is the Binary Coded Decimal (BCD) • ‘H’ = 0x48, ‘e’ = 0x65, … representation of 439 • \n = newline character is represented by either one or two ASCII character BCD Representation: This is the binary representation of 439 110110111 2 Unsigned Binary Rep.: (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