Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.

Slides:



Advertisements
Similar presentations
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Advertisements

2-1 Chapter 2 - Data Representation Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
Chapter 2: Data Representation
Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 2: Data Representation.
Faculty of Computer Science © 2006 CMPUT 229 Floating Point Representation Operating with Real Numbers.
Floating Point Numbers
Representations Example: Numbers –145 –CVL – –91 –
Assembly Language and Computer Architecture Using C++ and Java

Signed Numbers.
M68K Assembly Language Programming Bob Britton Chapter 12 IEEE Floating Point Notice: Chapter slides in this series originally provided by B.Britton. This.
Assembly Language and Computer Architecture Using C++ and Java
2-1 Computer Organization Part Fixed Point Numbers Using only two digits of precision for signed base 10 numbers, the range (interval between lowest.
Computer Science 210 Computer Organization Floating Point Representation.
Floating Point Numbers.  Floating point numbers are real numbers.  In Java, this just means any numbers that aren’t integers (whole numbers)  For example…
Lecture 8 Floating point format
Chapter 3 Data Representation part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Binary Representation and Computer Arithmetic
Dr. Bernard Chen Ph.D. University of Central Arkansas
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
The Binary Number System
Data Representation Number Systems.
Simple Data Type Representation and conversion of numbers
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Ch. 2 Floating Point Numbers
Information Representation (Level ISA3) Floating point numbers.
Computer Arithmetic Nizamettin AYDIN
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 22, 2004 Lecture Number: 24.
Computing Systems Basic arithmetic for computers.
Computer Architecture
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles of Computer.
COMPSCI 210 Semester Tutorial 1
CSE 111 Representing Numeric Data in a Computer Slides adapted from Dr. Kris Schindler.
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 29, 2004 Lecture Number: 26.
Data Representation - Part II. Characters A variable may not be a non-numerical type Character is the most common non- numerical type in a programming.
Data Representation in Computer Systems
S. Rawat I.I.T. Kanpur. Floating-point representation IEEE numbers are stored using a kind of scientific notation. ± mantissa * 2 exponent We can represent.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
CSC 221 Computer Organization and Assembly Language
Lecture 2 Binary Values and Number Systems. The number 943 is an example of a number written in positional notation. The relative positions of the digits.
AEEE2031 Data Representation and Numbering Systems.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Numbers in Computers.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
In decimal we are quite familiar with placing a “-” sign in front of a number to denote that it is negative The same is true for binary numbers a computer.
1 Ethics of Computing MONT 113G, Spring 2012 Session 4 Binary Addition.
Computer Organization 1 Data Representation Negative Integers.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Software Design and Development Storing Data Computing Science.
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
A brief comparison of integer and double representation
Dr. Clincy Professor of CS
Numbers in a Computer Unsigned integers Signed magnitude
CSCI206 - Computer Organization & Programming
Dr. Clincy Professor of CS
Dr. Clincy Professor of CS
CS 101 – Sept. 4 Number representation Integer Unsigned √ Signed √
Chapter3 Fixed Point Representation
Presentation transcript:

Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text

Review Last time we looked at several different representations of signed integers. We looked at signed binary numbers, where we used a leading zero or one to represent sign. We also looked at one's complement and two's complement numbers. This time – Review two's complement for the homework assignment. – Floating Point Representation

Review 2’s Compliment Two's complement numbers are used on most CPUs to represent signed integer values. Positive values are converted to negative values from regular sign and magnitudebinary representation using the following method: 1.bit flip 2.add one to the result Such values are converted back from negative to positive by undoing the operationsabove: 1.subtract one from the two's complement representation of the negative number 2.bit flip the result

Examples Using 5 bit binary numbers we may represent 10 as follows in signed magnitude representation: b = 10d Notice that in the representation above we have four bits representing the value and one bit (the leading zero) representing the sign (0 for positive and 1 for negative). Performing a bit flip on 10d yields the following result: 10101b Adding one yields the two's complement representation: 10110b = -10d (two's complement) Notice that in the example above there is a leading one representing that the number is negative. All one's complement, two's complement, and signed magnitude binary numbers have aleading zero or one to represent the value as positive or negative respectively.

Five bit 2’s Compliment Numbers 00000b = 0d 00001b = 1d11111b = -1d 00010b = 2d11110b = -2d 00011b = 3d11101b = -3d 00100b = 4d11100b = -4d 00101b = 5d11011b = -5d 00110b = 6d11010b = -6d 00111b = 7d11001b = -7d 01000b = 8d11000b = -8d 01001b = 9d10111b = -9d 01010b = 10d10110b = -10d 01011b = 11d10101b = -11d 01100b = 12d10100b = -12d 01101b = 13d10011b = -13d 01110b = 14d10010b = -14d 01111b = 15d10001b = -15d 10000b = -16d

Examples Examples of adding and subtracting these values follow below: 01010b = 10d = -10d b = 0d Subtraction or performing the operation a - b, can be represented as a + (-b).Take as an example. We first convert 3 to -3 and add -3 to 9 as follows: 01001b = 9d = -3d b = 6d

Examples Subtracting a negative number from another negative number is equally easy. We simply subtract one from the two's complement representation of the negative number and perform a bit flip. For example if we take -8 - (-4), the result should be -4. But to perform thisoperation as an addition, we need to convert -4 to b is the two's complement representation of b - 1b = 11011b Bit flipping 11011b yields 00100b = 4d Notice that in the example above we pretend is an unsigned binary number and subtract one. Now, our result from can be computed 11000b = -8d = 4d b = -4d

Floating Point Representation Representing real numbers in binary is quite simple and is not much different than converting from a decimal integer to binary. Consider 8.5d Notice that a value such as 8 can be represented as an unsigned binary integer as follows: 1000b Notice that values after the decimal point may be represented as a series of ones and zeroes representing the following values: 1/2, 1/4, 1/8, 1/16, 1/32,... Or 2^-1, 2^-2, 2^-3, 2^-4, 2^-5,... Thus, we have the following binary to decimal relationships 0.5d = 0.1b 0.25d = 0.01b d = 0.001b...

Floating Point Representation Additionally, notice that we can convert from decimal to binary by iteratively multiplying decimal fractions (values after the decimal point) by two until we reach a binary value. Notice that the values before the decimal point represent our binary fraction. Consider 0.5d 0.5d * <-- binary "decimal" point 1.0d Result is 0.1b = 2^-1 = 1/2 = 0.5d Consider 0.25d 0.25d * d * 2 1.0d Result is 0.01b = 0 * 2^ * 2^-2 = 1/4 = 0.25d

Floating Point Representation Consider 0.125d d * d * 2 0.5d * 2 1.0d Result is 0.001b = 0 * 2^ * 2^ * 2^-3 = 1/8 = 0.125d Consider another value such as 0.75d. A conversion to binary is performed as follows: 0.75d * d --> 0.5d*2 notice that we only multiply values after the decimal point by 1.0d Result is 0.11b = 1*2^-1 + 1*2^-2 = 1/2 + 1/4 = 3/4 = 0.75d

Floating Point Representation Now, lets look at 0.4d 0.4d * d * 2 1.6d --> 0.6d * 2 1.2d --> 0.2d * 2 0.4d * 2 0.8d * 2 1.6d --> 0.6d * 2 1.2d --> 0.2d * 2 0.4d * 2 0.8d * 2 1.6d --> 0.6d * 2 1.2d --> 0.2d * 2 0.4d * 2... Result is b = 0*2^-1 + 1*2^-2 + 1*2^-3 + 0*2^-4 + 0*2^-5 + 1*2^-6 + 1*2^-7 + 0*2^-8 + 0*2^-9 + 1*2^-10...

Floating Point Representation Notice that this result is an infinitely repeating series. Just like in decimal, where values suchas 1/3 may only be displayed as a decimal expansion of an infinitely repeating series, binary expansions may result in infinitely repeating series. If we sum 10 bits from the results of the binary expansion of 0.4d, we can get anapproximation for the value. Notice, 1/4 + 1/8 + 1/64 + 1/ /1024 = dThis is a near approximation to 0.4d

Example Consider a number such as d 123 % 2 = 1 61 % 2 = 1 30 % 2 = 0 15 % 2 = 1 7 % 2 = 1 3 % 2 = d * d * 2 1.8d --> 0.8d * 2 1.6d --> 0.6d * 2 1.2d --> 0.2d * 2 0.4d * 2 0.8d * 2 1.6d --> 0.6d * 2 1.2d --> 0.2d * 2 0.4d * 2 0.8d * 2 1.6d --> 0.6d * 2 1.2d --> 0.2d * 2 0.4d * 2... Now the result is:

IEEE Standard Again notice that we convert the values after the decimal point to binary by iterativelymultiplying all digits after the decimal point by two. Notice that if we are going to convert this to a representation that the computer can understand, we will have to limit the precision or the number of bits after the decimal place. IEEE Standard 754 denotes the standard representation for floating point numbers. 32 bit floating point numbers are represented in binary scientific notation. Recall that decimal floating point numbers are represented as follows: +/- x.xxxxx * 10 ^ +/- y where x is the significand and y is the exponent.

IEEE Standard In binary, we may represent scientific notation as: +/- x.xxxxxx * 2 ^ +/- y sign-bitexponentsignificand 1-bit8-bit23-bit The sign bit denotes whether the significand is positive or negative The exponent is a biased binary number and may represent a value between -126 and 127 The significand represents an unsigned binary value less than 2 decimal. Notice that this value will always be greater than or equal to one unless it is zero. Therefore, we will ignorethe leading one in the significand. Simply put, the significand denotes the significant bits of the value we are trying to represent.