Lecture 25: Other Number Systems

Similar documents
CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

CS101 Lecture 04: Binary Arithmetic

UNIT 7A Data Representation: Numbers and Text. Digital Data

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

Numeric Encodings Prof. James L. Frankel Harvard University

Chapter 3: Arithmetic for Computers

Floating Point Arithmetic

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude

Chapter 4. Operations on Data

Floating Point Arithmetic

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

Number System. Introduction. Decimal Numbers

CO212 Lecture 10: Arithmetic & Logical Unit

Number Systems. Both numbers are positive

Chapter 10 Binary Arithmetics

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3

CSE 20. Lecture 4: Number System and Boolean Function. CSE 20: Lecture2

CHW 261: Logic Design

Chapter 5 : Computer Arithmetic

CSCI 402: Computer Architectures. Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI.

Signed umbers. Sign/Magnitude otation

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

IEEE 754 Floating-Point Format

CS 101: Computer Programming and Utilization

Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

COMP2611: Computer Organization. Data Representation

MACHINE LEVEL REPRESENTATION OF DATA

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit

Number Systems CHAPTER Positional Number Systems

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

ECE232: Hardware Organization and Design

The type of all data used in a C (or C++) program must be specified

Introduction to Computers and Programming. Numeric Values

Inf2C - Computer Systems Lecture 2 Data Representation

Computer Sc. & IT. Digital Logic. Computer Sciencee & Information Technology. 20 Rank under AIR 100. Postal Correspondence

World Inside a Computer is Binary

EEM 232 Digital System I

The type of all data used in a C++ program must be specified

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

l l l l l l l Base 2; each digit is 0 or 1 l Each bit in place i has value 2 i l Binary representation is used in computers

Integers and Floating Point

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

D I G I T A L C I R C U I T S E E

EE 109 Unit 19. IEEE 754 Floating Point Representation Floating Point Arithmetic

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

Digital Fundamentals

Introduction to Scientific Computing Lecture 1

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

Floating Point. EE 109 Unit 20. Floating Point Representation. Fixed Point

Lecture 10: Floating Point, Digital Design

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

ECE331: Hardware Organization and Design

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Advanced Computer Architecture-CS501

CHAPTER 5: Representing Numerical Data

Review of Number Systems

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

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

EE 109 Unit 20. IEEE 754 Floating Point Representation Floating Point Arithmetic

Binary Arithmetic. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T.

Divide: Paper & Pencil

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

LABORATORY. 3 Representing Numbers OBJECTIVE REFERENCES. Learn how negative numbers and real numbers are encoded inside computers.

INF2270 Spring Philipp Häfliger. Lecture 4: Signed Binaries and Arithmetic

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

COMPUTER ARITHMETIC (Part 1)

Hybrid Electronics Laboratory

Lecture 2: Number Systems

ESc101 : Fundamental of Computing

9/10/10. Arithmetic Operators. Today. Assigning floats to ints. Arithmetic Operators & Expressions. What do you think is the output?

Chapter 4: Data Representations

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

CMPE223/CMSE222 Digital Logic Design. Positional representation

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

Objectives. Connecting with Computer Science 2

Lecture 10: Floating Point, Digital Design

Numbering systems. Dr Abu Arqoub

Building a Test Suite

SE311: Design of Digital Systems

Signed Multiplication Multiply the positives Negate result if signs of operand are different

COPYRIGHTED MATERIAL. Number Systems. 1.1 Analogue Versus Digital

T02 Tutorial Slides for Week 2

Computer Architecture Chapter 3. Fall 2005 Department of Computer Science Kent State University

Up next. Midterm. Today s lecture. To follow

IEEE Standard for Floating-Point Arithmetic: 754

Lecture 6: Signed Numbers & Arithmetic Circuits. BCD (Binary Coded Decimal) Points Addressed in this Lecture

CHAPTER 1 Numerical Representation

±M R ±E, S M CHARACTERISTIC MANTISSA 1 k j

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

MYcsvtu Notes DATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes

CPE300: Digital System Architecture and Design

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

Administrivia. CMSC 216 Introduction to Computer Systems Lecture 24 Data Representation and Libraries. Representing characters DATA REPRESENTATION

Software and Hardware

The. Binary. Number System

INTEGER REPRESENTATIONS

Transcription:

Lecture 25: Other Number Systems

Today s Goals Learn about Gray Codes Use scaled binary numbers Learn the IEEE floating point number format

Gray Codes Rotational Position Encoded with Standard Binary Gray Code 6 5 6 5 7 4 7 4 0 3 0 3 1 2 1 2 Gray Code, also known as the reflected binary code, is a binary number system in which two adjacent values are different by only one bit. From Digital System 1, Karnaugh map (K-map) uses Gray Code to simplify Boolean algebra expressions.

Generating a Gray Code Start t with a 1 bit code. 0 0 0 0 Double the number of values by mirroring the current code, appending 0 s to the beginning of the original copy and 1 s to the beginning of the new copy. Repeat this process until enough values are available. Note: 0 0 0 1 0 0 1 1 0 0 1 0 0 1 1 0 0 1 1 1 0 1 0 1 0 1 0 0 1 1 0 0 1 1 0 1 1 1 1 1 You can create a slightly smaller Gray Code by deleting the same number of values from the 1 1 1 0 top of the list as you do from the bottom. 1 0 1 0 A Gray Code must have an even number of 1 0 1 1 values. 1 0 0 1 1 0 0 0

Scaled Binary When a program requires very large numbers, very small numbers, or number with fractions, programmers often turn to floating point numbers. USAGDP DC.W 1 ; USA s gross domestic product ; in billions of dollars CANGDP DC.W 1 ; Canada s gross domestic product ; in billions of dollars WAVEON DC.W 1 ; Waveform on time in 0.001 s 001 s of a sec. WAVEONF DC.W 1 ; Waveform off time in 0.001 s of a sec. Note: The resolution is determined by the scaling factor, which is the drawback to this approach.

Using Binary Fractions Floating point arithmetic takes much more time to perform than integer arithmetic, and it should be minimally used. A binary number can contain a fraction component if the radix point is moved to the left. In decimal, a radix point is commonly called the decimal point. Moving the radix point has the same effect in binary that it does in decimal, as illustrated with the examples below. Examples: What decimal value does 000011.11 2 represent? 3.75 10 What decimal value does 11111.1111 2c represent? -0.0625 10 Notes: When performing arithmetic, all numbers must have the radix point in the same location. The radix point is tracked by the programmer, not the processor.

Converting to a Binary Fraction The integer portion and fraction portion are converted separately. The integer portion is converted as before. For the fraction, 1. Multiply the decimal fraction by two. 2. Record the digit to the left of the decimal point in the result as the next least significant digit. Repeat (note: ignore the integer portion) the above two steps until the fraction is zero (terminating fraction), or the fraction is the same as from a previous step (repeating fraction). Examples: Represent 6.375 10 in 8-bit unsigned binary. Place the radix point where desired. 00110.011 2 0110.0110 2 110.01100 2 Represent 0.4 10 in 8-bit unsigned binary. Place the radix point where desired..01100110 2

Floating Point Floating point numbers were designed d to be used when both very large and very small numbers needed to be used simultaneously. To do this, a floating point number includes the scaling factor that was assumed by the programmer when using scaled binary. A floating point number contains three values: Sign bit - most floating point systems used today are sign and magnitude) Exponent scaling factors are limited to powers of 2 Fraction

IEEE Floating Point IEEE established a standard d format, described d briefly below. S Exponent: 8 bits Fraction: 23 bits Except for 0, values are normalized. This means a number is scaled so that 1 fraction < 2. Since the normalized value is always 1.fraction, the leading 1 is assumed and not stored in the fraction. The value represented is (-1) S (2 (E-127) )(1.fraction) An exponent of 255 is reserved for infinity and not-anumber. An exponent of 0 either means 0 (if fraction is 0) or the An exponent of 0 either means 0 (if fraction is 0) or the minimum exponent (if fraction is not 0).

Examples S Exponent: 8 bits Fraction: 23 bits (-1) S (2 (E-127) )(1.fraction) More examples C11900000 16-9.5625 3CDC0000 16 0.02685546875 16 Calcuator: http://babbage.cs.qc.edu/ieee-754/32bit.html

Questions?

Wrap-up What we ve learned

What to Come