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

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

Inf2C - Computer Systems Lecture 2 Data Representation

MACHINE LEVEL REPRESENTATION OF DATA

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

Announcement. (CSC-3501) Lecture 3 (22 Jan 2008) Today, 1 st homework will be uploaded at our class website. Seung-Jong Park (Jay)

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

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

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

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

CHW 261: Logic Design

Digital Fundamentals

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

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

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

COMP2121: Microprocessors and Interfacing. Number Systems

Digital Fundamentals

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

COMP Overview of Tutorial #2

Digital Computers and Machine Representation of Data

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

COMP2611: Computer Organization. Data Representation

LING 388: Computers and Language. Lecture 5

Divide: Paper & Pencil

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

Objectives. Connecting with Computer Science 2

Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction

Module 2: Computer Arithmetic

Floating Point Arithmetic

Introduction to Computers and Programming. Numeric Values

Data Representation 1

ECE232: Hardware Organization and Design

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

T02 Tutorial Slides for Week 2

Chapter Three. Arithmetic

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

Data Representation and Networking

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

CS101 Lecture 04: Binary Arithmetic

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

Chapter 4: Data Representations

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Topic Notes: Bits and Bytes and Numbers

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

CS61c Midterm Review (fa06) Number representation and Floating points From your friendly reader

Chapter 2. Data Representation in Computer Systems

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

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

CS 101: Computer Programming and Utilization

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Chapter 3: Arithmetic for Computers

Topic Notes: Bits and Bytes and Numbers

Binary Codes. Dr. Mudathir A. Fagiri

Basic data types. Building blocks of computation

Number Systems. TA: Mamun. References: Lecture notes of Introduction to Information Technologies (ITEC 1011) by Dr Scott MacKenzie

Computer Systems C S Cynthia Lee

IEEE Standard for Floating-Point Arithmetic: 754

CO212 Lecture 10: Arithmetic & Logical Unit

Final Labs and Tutors

Adding Binary Integers. Part 5. Adding Base 10 Numbers. Adding 2's Complement. Adding Binary Example = 10. Arithmetic Logic Unit

Characters, Strings, and Floats

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.

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Number Systems Base r

Organisasi Sistem Komputer

Number Systems CHAPTER Positional Number Systems

FLOATING POINT NUMBERS

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

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

Number Systems & Encoding

Floating Point Numbers. Lecture 9 CAP

Computer Organization

QUIZ: Generations of computer technology. Hardware:

QUIZ ch.1. 1 st generation 2 nd generation 3 rd generation 4 th generation 5 th generation Rock s Law Moore s Law

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

BINARY SYSTEM. Binary system is used in digital systems because it is:

DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

Data Representation. DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

M1 Computers and Data

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

Chapter 4: Computer Codes. In this chapter you will learn about:

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

Chapter 2 Data Representations

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

Thus needs to be a consistent method of representing negative numbers in binary computer arithmetic operations.

CHAPTER 2 Data Representation in Computer Systems

Chapter 2 Bits, Data Types, and Operations

CHAPTER 2 Data Representation in Computer Systems

World Inside a Computer is Binary

Electronic Data and Instructions

OBJECTIVES After reading this chapter, the student should be able to:

Operations On Data CHAPTER 4. (Solutions to Odd-Numbered Problems) Review Questions

15213 Recitation 2: Floating Point

Data Representations & Arithmetic Operations

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

CSC201, SECTION 002, Fall 2000: Homework Assignment #2

3.5 Floating Point: Overview

Chapter 3: Number Systems and Codes. Textbook: Petruzella, Frank D., Programmable Logic Controllers. McGraw Hill Companies Inc.

Introduction to Informatics

A Level Computing. Contents. For the Exam:

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

Transcription:

Announcements Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit Quiz 2 Monday on Number System Conversions Covers lectures on computer number systems Covers all types of problems in Homework 1 Try practice problems (posted to class schedule) CSC 242 - Computer Organization 1

Representing Real Numbers: Floating Point Finale CSC 242 Computer Organization Dr. Lucas Layman January 31, 2018

IEEE 754 Standard for Floating-Point Arithmetic Defines a different format for storing real numbers Specify rules for communicating real numbers between components Rounding rules Arithmetic operations Exception handling (division by zero, overflow, etc) CSC 242 - Computer Organization 3

IEEE 754 generalized process 1) Convert the integer and significand from decimal to binary 2) Normalize the binary, a.k.a., convert it to scientific notation in binary 3) Store the key values of the normalized binary this is the floating point representation CSC 242 - Computer Organization 4

1) Convert the integer and significand from decimal to binary Example: convert 2.625 10 to 8-bit binary Algorithm: a) Convert the integer part (2) to binary using successive division. b) Convert the significand (.625) to binary using successive multiplication: 1) Multiply only the significand by 2 2) Note the integer value (1 or 0). These are your binary significands starting with the MSB. 3) Repeat steps 1-2 until your significand is 0 or you hit the maximum number of bits c) Write the binary CSC 242 - Computer Organization 5

2) Normalize the binary Move the radix point so that it is one bit from the left. Adjust the exponent so that the value does not change. 2.625 10 = 10.101000 2 = 0.40625 10 = 0.01101 2 = 3.14159 10 = 11.001001 2 = CSC 242 - Computer Organization 6

3) Store the key values of the normalized binary 1) the sign 3) the exponent 3.14 10 = ±1.1001001 x 2 1 2) the significand CSC 242 - Computer Organization 7

3) Store the key values of the normalized binary exponent 3 bits An 8-bit float (1 byte): 0 1 1 0 1 1 1 1 sign bit significand 4 bits Note: 8-bit floats aren t very useful, but they illustrate the process. Modern computers use 32- and 64-bit floats. CSC 242 - Computer Organization 8

3) Store the key values of the normalized binary (cont.) 3.14159 10 = +1.1001001 x 2 1 exponent 3 bits Sign bit: 1 = negative, 0 = non-negative Exponent bits: sign bit Take the exponent and add the bias to it. The bias is always 2 k-1-1 where k is the number of bits in the exponent field. Convert the exponent (with added bias) to binary. Significand bits: take the first m bits of your normalized binary s significand significand 4 bits CSC 242 - Computer Organization 9

3) Store the key values of the normalized binary (cont.) 3.14159 10 = ±1.1001001 x 2 1 exponent 3 bits Sign bit: Exponent bits: We have dropped this 1. It is implied. sign bit mantissa 4 bits Significand bits: CSC 242 - Computer Organization 10

3) Store the key values of the normalized binary (cont.) -0.40625 10 = 1.10100 x 2-2 exponent 3 bits Sign bit: Exponent bits: We have dropped this 1. It is implied. sign bit significand 4 bits Significand bits: CSC 242 - Computer Organization 11

Once more, beginning to end Convert -14.6875 to 8-bit IEEE 754 floating point 1) 14.6875 to binary: 2) Normalize: 3) Store values: 1) Sign bit: 2) Exponent: 3) Significand: Answer: exponent 3 bits sign bit significand 4 bits CSC 242 - Computer Organization 12

Floats in modern computers A single-precision float is 4 bytes, or 32 bits: exponent 8 bits 0 1 1 0 0 1 1 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0 1 0 1 1 1 1 sign bit significand 23 bits CSC 242 - Computer Organization 13

Floats in modern computers (cont.) A double-precision float is 8 bytes, or 64 bits. Python uses this by default. 8 bit 32 bit 64 bit exponent 11 bits significand 52 bits CSC 242 - Computer Organization 14

Converting to IEEE 32-bit floating point format Convert -1313.3125 10 (process is the same as 8-bit) 1) Convert the integer and significand from decimal to binary (example 3) -> 10100100001.0101 2 2) Normalize: 1.01001000010101 x 2 10 3) Store the key values of the normalized binary: Sign bit: 1 Exponent: 10+127 = 137 10 = 10001001 2 Note: The bias for a 32 bit floating point # is always 127 Significand: 01001000010101000000000 CSC 242 - Computer Organization 15

Converting to IEEE 32-bit floating point format (cont.) -1313.3125 10 = Sign bit: 1 Exponent: 10+127 = 137 10 = 10001001 2 Significand: 01001000010101000000000 exponent 8 bits 1 1 0 0 0 1 0 0 1 0 1 0 0 1 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 sign bit significand 23 bits CSC 242 - Computer Organization 16

Another 32-bit example Convert -78.5625 10 to 32-bit floating point 1) Convert the integer and significand from decimal to binary 2) Normalize the binary 3) Store the key values of the normalized binary 1) sign bit 2) exponent (remember the bias is 127) 3) the significand to 23 bits CSC 242 - Computer Organization 17

Review on computer representations of numbers Name Base Range Purpose Decimal 10 [0,9] The number system most humans use Binary 2 [0,1] The language of all computers Octal 8 [0,7] Rarely used. Common in early computers Hex 16 [0,F] user-friendly representation of binary data CSC 242 - Computer Organization 18

Review on computer representations of numbers Name Base Purpose Two s complement 2 A way to represent signed integers Floating point Any A way to represent real numbers CSC 242 - Computer Organization 19

Storing other types of data We ve discussed storing integers and real numbers But binary bits/bytes can also store: Pixel data for images (e.g., color codes) Digital audio (e.g., compressed or uncompressed waveforms) Program instructions (e.g., from Python or Java) Alphabet characters for display on the monitor Everything is stored in binary, but what the binary represents depends on how the binary is used CSC 242 - Computer Organization 20

One example ASCII ASCII American Standard Code for Information Interchange 128 characters (including null) represented by 2 7 bits. Characters are usually referred to by their 2-digit hex: 00-7F. Developed in the 60 s when Bell telephone created a digital telegraph CSC 242 - Computer Organization 21

CSC 242 - Computer Organization 22

Unicode There are other characters than in ASCII Unicode consortium handles all the characters in the world. Unicode specifies the international standard for representing characters, including emojis CSC 242 - Computer Organization 23