EE 109 Unit 3. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

Similar documents
EE 109 Unit 2. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

Unit 3. Analog vs. Digital. Analog vs. Digital ANALOG VS. DIGITAL. Binary Representation

EE 109 Unit 2. Binary Representation Systems

3.1. Unit 3. Binary Representation

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations

Fundamentals of Programming (C)

Chapter 2 Bits, Data Types, and Operations

1.1. Unit 1. Integer Representation

Chapter 2 Number System

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

DATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes. Error Detection Codes

Data Representation and Binary Arithmetic. Lecture 2

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

CPS 104 Computer Organization and Programming Lecture-2 : Data representations,

Chapter 2 Bits, Data Types, and Operations

Fundamentals of Programming

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS

Number System (Different Ways To Say How Many) Fall 2016

Number Representations

CMSC 313 Lecture 03 Multiple-byte data big-endian vs little-endian sign extension Multiplication and division Floating point formats Character Codes

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers

Number Systems Base r

Chapter 2 Bits, Data Types, and Operations

Oberon Data Types. Matteo Corti. December 5, 2001

Data Representa5on. CSC 2400: Computer Systems. What kinds of data do we need to represent?

Exercises Software Development I. 03 Data Representation. Data types, range of values, internal format, literals. October 22nd, 2014

Data Representa5on. CSC 2400: Computer Systems. What kinds of data do we need to represent?

Chapter 3. Information Representation

Binary Numbers. The Basics. Base 10 Number. What is a Number? = Binary Number Example. Binary Number Example

Positional Number System

Bits and Bytes. Data Representation. A binary digit or bit has a value of either 0 or 1; these are the values we can store in hardware devices.

SIGNED AND UNSIGNED SYSTEMS

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012

5/17/2009. Digitizing Discrete Information. Ordering Symbols. Analog vs. Digital

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

Under the Hood: Data Representation. Computer Science 104 Lecture 2

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, SPRING 2013

2a. Codes and number systems (continued) How to get the binary representation of an integer: special case of application of the inverse Horner scheme

Number System. Introduction. Decimal Numbers

Fundamental Data Types

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012

ASSIGNMENT 5 TIPS AND TRICKS

Number Systems II MA1S1. Tristan McLoughlin. November 30, 2013

Simple Data Types in C. Alan L. Cox

CS341 *** TURN OFF ALL CELLPHONES *** Practice NAME

Chapter 8. Characters and Strings

Do not start the test until instructed to do so!

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

CPSC 301: Computing in the Life Sciences Lecture Notes 16: Data Representation

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

Do not start the test until instructed to do so!

The Binary Number System

MACHINE LEVEL REPRESENTATION OF DATA

Chapter 1. Hardware. Introduction to Computers and Programming. Chapter 1.2

Source coding and compression

CSC 8400: Computer Systems. Represen3ng and Manipula3ng Informa3on. Background: Number Systems

Do not start the test until instructed to do so!

Chap 1. Digital Computers and Information

Unit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions. Mr. Dave Clausen La Cañada High School

Digital Systems COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

EXPERIMENT 8: Introduction to Universal Serial Asynchronous Receive Transmit (USART)

UNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES

PureScan - ML1. Configuration Guide. Wireless Linear Imager Wireless Laser scanner - 1 -

CSE-1520R Test #1. The exam is closed book, closed notes, and no aids such as calculators, cellphones, etc.

CSE-1520R Test #1. The exam is closed book, closed notes, and no aids such as calculators, cellphones, etc.

Experiment 3. TITLE Optional: Write here the Title of your program.model SMALL This directive defines the memory model used in the program.

Introduction. Chapter 1. Hardware. Introduction. Creators of Software. Hardware. Introduction to Computers and Programming (Fall 2015, CSUS)

Lecture (09) x86 programming 8

EXPERIMENT 7: Introduction to Universal Serial Asynchronous Receive Transmit (USART)

S-Series Sensor ASCII Protocol v8.1.0

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Digital Representation

Table of Contents Sleep Settings How to Configure the Scanner. 7 Chapter 2 System Setup

Chemistry Hour Exam 2

COMP2611: Computer Organization. Data Representation

Logic and Computer Design Fundamentals. Chapter 1 Digital Computers and Information

This is great when speed is important and relatively few words are necessary, but Max would be a terrible language for writing a text editor.

Lecture (01) Digital Systems and Binary Numbers By: Dr. Ahmed ElShafee

Introduction to Numbering Systems

Imperial College London Department of Computing

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

World Inside a Computer is Binary

Lecture (01) Introduction Number Systems and Conversion (1)

Introduction to Decision Structures. Boolean & If Statements. Different Types of Decisions. Boolean Logic. Relational Operators

Appendix A Developing a C Program on the UNIX system

Serial I/O. 4: Serial I/O. CET360 Microprocessor Engineering. J. Sumey

= Chapter 1. The Binary Number System. 1.1 Why Binary?

CSE 30 Spring 2006 Final Exam

FD-011WU. 2D Barcode Reader User Guide V1.6CC

SE311: Design of Digital Systems

CSE 30 Spring 2007 Final Exam

Chapter 7. Binary, octal and hexadecimal numbers

ASCII Code - The extended ASCII table

MC1601 Computer Organization

RS-232 Control of the Advantage EQ281/8, EQ282/8 and Advantage SMS200

Review. Single Pixel Filters. Spatial Filters. Image Processing Applications. Thresholding Posterize Histogram Equalization Negative Sepia Grayscale

COMP2121: Microprocessors and Interfacing. Number Systems

Transcription:

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

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

3.9 3. Interpreting Binary Strings Given a string of s and s, you need to know the representation systembeing used, before you can understand the value of those s and s. DIGITAL REPRESENTATION Unsigned Binary system =? s complement system BCD 5 9 BCD - s comp. 3. 3. Binary Representation Systems Integer Systems Unsigned Unsigned (Normal) binary Signed Signed Magnitude s complement Excess-N* s complement* Floating Point For very large and small (fractional) numbers Codes Text ASCII / Unicode Decimal Codes BCD (Binary Coded Decimal) / (8 Code) Number Systems Number systems consist of.. coefficients/digits: Human System: Decimal (Base ):,,,3,,5,6,7,8,9 Computer System: Binary (Base ):, Human systems for working with computer systems (shorthand for human to read/write binary) * = Not fully covered in this class

3.3 3. Positional Number Systems (Unsigned) Base r: Implicit Place Values: Explicit Coefficients: Left-most digit = Right-most digit = (76) 8 = (A5) 6 = Examples Decimal:... a 3 a a a. a - a -... (.) = Binary: N r = () = 3.5 3.6 Powers of Practice On Your Own = = = 3 = 8 = 6 5 = 3 6 = 6 7 = 8 8 = 56 9 = 5 = 5 56 8 6 3 6 8 Decimal equivalent is the sum of each coefficient multiplied by its implicit place value (power of the base) () = (653) 8 = = Σ i (a i * r i ) [a i = coefficient, r = base] (AD) 6 =

3.7 3.8 Unique Combinations Approximating Large Powers of Given ndigits of base r, how many unique numbers can be formed? What is the range? -digit, decimal numbers (r=, n=) 3-digit, decimal numbers (r=, n=3) -bit, binary numbers (r=, n=) 6-bit, binary numbers (r=, n=6) - - -9 - -9 - Often need to find decimal approximation of a large powers of like 6, 3, etc. Use following approximations: 3 For other powers of, decompose into product of or or 3 and a power of that is less than 6 = 6 * = 8 = 3 = 6 = 3.9 3. Decimal to Unsigned Binary Decimal to Unsigned Binary Now lets convert from decimal to binary To convert a decimal number, x, to binary: Only coefficients of or. 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 in those place values and in all others 73 = 87 = 5 = 8 6 3 6 8 5 = 3 6 8.65 =.5.5.5.65.35

3. 3. 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. 75 = 56 6 hex Unsigned and Signed Normal (unsigned) binary can only represent positive numbers All place values are positive To represent negative numbers we must use a modified binary representation that takes into account sign (pos. or neg.) We call these signed representations 3.3 3. Signed Number Representation Signed numbers Primary Systems.. All systems used to represent negative numbers split the possible binary combinations in half (half for positive numbers / half for negative numbers) In both signed magnitude and s complement, positive and negative numbers are separated using the = means = means

3.5 3.6 Signed Magnitude System Signed Magnitude Examples Use binary place values but now MSB represents the sign ( if negative, if positive) -bit Unsigned 3 8 to 5 -bit Signed Magnitude +/- +/- = -5 = +3 = -7 Notice that +3 in signed magnitude is the same as in the unsigned system -bit Signed Magnitude 3-7 to +7 +/- = -9 8-bit Signed Magnitude 7 +/- +/- 6 6 5 3 6 3 8-7 to +7 8-bit Signed Magnitude +/- 6 3 6 8 = +5 +/- 6 3 6 8 Important: Positive numbers have the same representation in signed magnitude as in normal unsigned binary 3.7 3.8 s Complement System s Complement Examples Normal binary place values except MSB of means -bit Unsigned 3 8 to 5 -bit s complement = = = -bit s complement 3 8-bit s complement = = 8-bit s complement 7 6 6 5 3 6 3 8 Important: numbers have the same representation in s complement as in normal unsigned binary

s Complement Range Given n bits Max positive value = Max negative value = Range with n-bits of s complement Side note What decimal value is? 3.9 Comparison of Systems - -5-3 -7 + Signed -6 + Mag. ++ - - +3-3 +3 s comp. - + + - -5-6 - +5 +6-7 +7-8 +6 +7 - +5 3.3 Unsigned and Signed Variables 3.3 IMPORTANT NOTE 3.3 In C, unsigned variables use (normal power-of- place values) to represent numbers = +7 8 6 3 6 8 In C, signed variables use the system (Neg. MSB weight) to represent numbers = -9-8 6 3 6 8 All computer systems use the 's complement system to represent signed integers! So from now on, if we say an integer is signed, we are actually saying it uses the 's complement systemunless otherwise specified We will not use "signed magnitude" unless explicitly indicated

3.33 3.3 Zero and Sign Extension Extension is the process of increasing the number of bits used to represent a number without changing its value Unsigned = = Zero and Sign Truncation Truncation is the process of decreasing the number of bits used to represent a number without changing its value Unsigned = = s complement = s complement = pos. = pos. = neg. = neg. = 3.35 3.36 Review Data Representation Unsigned Signed Mag. s Complement In C/C++ variables can be of different types and sizes Integer Types (signed and unsigned) C Type Bytes s MIPS Name ATmega38 [unsigned] char [unsigned] short [int] Decimal Equivalent [unsigned] long [int] - [unsigned] long long[int] - Unsigned s comp. Can emulate but has no single-instruction support xd Floating Point Types xef C Type Bytes s MIPS Name ATmega38 float Minimum bit representation double

3.37 Binary, Octal, and Hexadecimal 3.38 Hexadecimal and Octal SHORTHAND FOR BINARY Octal (base 8 = 3 ) Octal digit ( _ ) 8 can represent: 3 bits of binary ( _) can represent: Conclusion Hex (base 6= ) Hex digit ( _ ) 6 can represent: bits of binary ( ) can represent: Conclusion Binary to Octal or Hex 3.39 Octal or Hex to Binary 3. Octal Make groups of bits starting from radix point and working outward Add s where necessary Convert each group to an octal digit. Hex Make groups of bits starting from radix point and working outward Add s where necessary Convert each group to an octal digit. Expand each octal digit to a group of bits Expand each hex digit to a group of bits 37. 8 D93.8 6

Hexadecimal Representation 3. 3. Since values in modern computers are many bits, we use hexadecimal as a shorthand notation ( bits = hex digit) = D hex or xdif you write it in C/C++ = 76CB hex or x76cbif you write it in C/C++ Important Point: To interpret the value of a hex number, you must know what underlying binary system is assumed (unsigned, s comp. etc.) D hex (what if underlying binary system is unsigned?) D hex (what if underlying binary system is signed?) D hex ( = 'Ò' in Arial Unicode font) ASCII & Unicode BINARY CODES Binary Representation Systems Integer Systems Unsigned Unsigned (Normal) binary Signed Signed Magnitude s complement s complement* Excess-N* Floating Point For very large and small (fractional) numbers Codes Text ASCII / Unicode Decimal Codes BCD (Binary Coded Decimal) / (8 Code) 3.3 Binary Codes Using binary we can represent any kind of information by coming up with a code Using nbits we can represent n distinct items Colors of the rainbow: Red = Orange = Yellow = Green = Blue = Purple = Letters: A = B = C =... Z = 3. * = Not covered in this class

3.5 3.6 ASCII Code Used for representing text characters Originally 7-bits but usually stored as 8-bits = -byte in a computer Example: "Hello\n"; Each character is converted to ASCII equivalent H = x8, e = x65, \n = newline character is represented by either one or two ASCII character ASCII Table LSD/MSD 3 5 6 7 NULL DLW SPACE @ P ` p SOH DC! A Q a q STX DC B R b r 3 ETX DC3 # 3 C S c s EOT DC $ D T d t 5 ENQ NAK % 5 E U e u 6 ACK SYN & 6 F V f v 7 BEL ETB 7 G W g w 8 BS CAN ( 8 H X h x 9 TAB EM ) 9 I Y i y A LF SUB * : J Z j z B VT ESC + ; K [ k { C FF FS, < L \ l D CR GS - = M ] m } E SO RS. > N ^ n ~ F SI US /? O _ o DEL 3.7 UniCode ASCII can represent only the English alphabet, decimal digits, and punctuation 8-bit code => = characters It would be nice to have one code that represented more alphabets/characters for common languages used around the world Unicode 6-bit Code => characters Represents many languages alphabets and characters Used by Java as standard character code Unicode hex value (i.e. FB5 => )