NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.

Slides:



Advertisements
Similar presentations
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
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.
©Brooks/Cole, 2003 Chapter 4 Operations on Bits. ©Brooks/Cole, 2003 Apply arithmetic operations on bits when the integer is represented in two’s complement.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Floating Point Numbers
Lecture 3 Number Representation 2 This week – Recap Addition – Addition circuitry – Subtraction of integers in binary – Representing numbers with fractional.
Assembly Language and Computer Architecture Using C++ and Java
1 Lecture 3 Bit Operations Floating Point – 32 bits or 64 bits 1.
Signed Numbers.
Floating Point Numbers
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
Floating Point Numbers
Chapter 3 Number Representation
Number Representation Rizwan Rehman, CCS, DU. Convert a number from decimal to binary notation and vice versa. Understand the different representations.
1 Binary Numbers Again Recall that N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to bits.
Floating Point Numbers.  Floating point numbers are real numbers.  In Java, this just means any numbers that aren’t integers (whole numbers)  For example…
Operations on data CHAPTER 4.
4 Operations On Data Foundations of Computer Science ã Cengage Learning.
Chapter 3 Data Representation part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Binary Representation and Computer Arithmetic
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
Simple Data Type Representation and conversion of numbers
Chapter 3 Number Representation. Convert a number from decimal 、 hexadecimal,octal to binary notation and vice versa. Understand the different representations.
Binary Representation. Binary Representation for Numbers Assume 4-bit numbers 5 as an integer  as an integer  How? 5.0 as a real number  How?
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
Chapter 1 Data Storage(3) Yonsei University 1 st Semester, 2015 Sanghyun Park.
Studies in Big Data 4 Weng-Long Chang Athanasios V. Vasilakos MolecularComputing Towards a Novel Computing Architecture for Complex Problem Solving.
Computer Architecture
Data Representation.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
Lecture 4 Last Lecture –Positional Numbering Systems –Converting Between Bases Today’s Topics –Signed Integer Representation Signed magnitude One’s complement.
Lecture 5. Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Chapter 3 Number Representation. Convert a number from decimal to binary notation and vice versa. Understand the different representations of an integer.
BR 8/99 Binary Numbers Again Recall than N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to 255.
CSC 221 Computer Organization and Assembly Language
Number Representation
Integer & Floating Point Representations CDA 3101 Discussion Session 05.
©Brooks/Cole, 2003 Chapter 4 Operations on Bits. ©Brooks/Cole, 2003 Apply arithmetic operations on bits when the integer is represented in two’s complement.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Computer Organization and Design Information Encoding II Montek Singh Wed, Aug 29, 2012 Lecture 3.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Addition and Substraction
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
IT1004: Data Representation and Organization Negative number representation.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.7 Instructor: Lin Chen Sept 2013.
ECE 3110: Introduction to Digital Systems Number Systems: signed numbers.
Chapter 4 Operations on Bits. Apply arithmetic operations on bits when the integer is represented in two’s complement. Apply logical operations on bits.
1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
Floating Point Numbers
Department of Computer Science Georgia State University
Fundamentals of Computer Science
Chapter 4 Operations on Bits.
Floating Point Number system corresponding to the decimal notation
Data Structures Mohammed Thajeel To the second year students
Number Representation
Chapter 3 DataStorage Foundations of Computer Science ã Cengage Learning.
CPS120: Introduction to Computer Science
Chapter3 Fixed Point Representation
OBJECTIVES After reading this chapter, the reader should be able to :
靜夜思 床前明月光, 疑是地上霜。 舉頭望明月, 低頭思故鄉。 ~ 李白 李商隱.
1.6) Storing Integer: 1.7) storing fraction:
Presentation transcript:

NUMBER REPRESENTATION CHAPTER 3 – part 3

ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3

Integer Representation UnsignedSigned Sign and Magnitude One’s Complement Two’s Complement

One’s complement integers

Table 3.5 Range of One’s complement integers # of Bits # of Bits Range  127  0   0   ,147,483,647

One’s complement integers There are two 0s in There are two 0s in One’s complement representation: positive and negative. In an 8-bit allocation: +0   There are two 0s in There are two 0s in One’s complement representation: positive and negative. In an 8-bit allocation: +0  

One’s complement integers In one’’s complement representation, the leftmost bit defines the sign of the number. If it is 0, the number is positive. If it is 0, the number is positive. If it is 1, the number is negative In one’’s complement representation, the leftmost bit defines the sign of the number. If it is 0, the number is positive. If it is 0, the number is positive. If it is 1, the number is negative

One’s complement integers Storing One’s complement integer process: 1. The integer is changed to binary, (the sign is ignored). 2. 0s are added to the left of the number to make a total of N 3. bits 4. If the sign is positive, no more action is needed. If the sign is negative, every bit is complemented

Store +7 in an 8-bit memory location using one’s complement representation.  The integer is changed to binary (111).  Add 5 0s to make a total of N (8) bits,  The sign is positive so no more action is needed Example 4 Solution

Example 5 Solution

One’s complement integers Table 3.6 Example of storing one’s complement integers in two computers Decimal Decimal − − ,760 −24,760 8-bit allocation overflow 16-bit allocation

One’s complement integers

Example 6 Solution

The one’s complement representation is not used now by computers because:  Operations: such as subtraction and addition is not straightforward for this representation.  Uncomfortable in programming: because there are two 0s in this representation One’s complement Applications

However.. The advantage of this representation is: 1. It’s the foundation of the next representation(Two’s complement) 2. It has properties that make it interesting for data communication applications such as error detection and correction One’s complement Applications

TWO’S COMPLEMENT REPRESENTATION

Integer Representation UnsignedSigned Sign and Magnitude One’s Complement Two’s Complement

Two’s complement integers It’s… The most common The most important The most widely used representation today

Two’s complement integers Table 3.7 Range of Two’s complement integers # of Bits # of Bits Range  128  0   0   ,147,483,647

Two’s complement integers There is Only one 0 in There is Only one 0 in Two’s complementrepresentation In an 8-bit allocation: 0  There is Only one 0 in There is Only one 0 in Two’s complementrepresentation In an 8-bit allocation: 0 

Two’s complement integers In two’s complement representation, the leftmost bit defines the sign of the number. If it is 0, the number is positive. If it is 0, the number is positive. If it is 1, the number is negative In two’s complement representation, the leftmost bit defines the sign of the number. If it is 0, the number is positive. If it is 0, the number is positive. If it is 1, the number is negative

Two’s complement integers Storing One’s complement integer process: 1. The number is changed to binary, (the sign is ignored). 2. 0s are added to the left of the number to make a total of N bits 3. If the sign is positive, no more action is needed. If the sign is negative, leave all the rightmost 0’s and the first 1 unchanged. Then complement the rest of the bits.

Store +7 in an 8-bit memory location using two’s complement representation.  The integer is changed to binary (111).  Add 5 0s to make a total of N (8) bits,  The sign is positive so no more action is needed Example 4 Solution

Example 5 Solution

Two’s complement integers Table 3.8 Example of storing two’s complement integers in two computers Decimal Decimal − − ,760 −24,760 8-bit allocation overflow 16-bit allocation

Two’s complement integers

Example 6 Solution

The two’s complement representation is the standard representation used for storing integers by computers today because it makes the operations simple. Two’s complement Applications

SUMMARY OF INTEGER REPRESENTATION Unsigned Sign & magnitude One’s complement Two’s complement

One’s complement Sign & magnitude Unsigned Contents of Memory

EXCESS SYSTEM

Excess System

Example

Excess System Representation To represent a number in Excess, use the following procedure:  ‰ Add the magic number to the integer  ‰ Change the result to binary and add 0s so that there is a total of N bits

Excess System Representation

Excess System Interpretation To interpret a number in Excess, use the following procedure:  ‰Change the number to decimal  Subtract the magic number from the integer

Excess System Interpretation

FLOATING POINT REPRESENTATION

Floating point representation Floating point number = a number containing an integer & a fraction Example: IntegerFraction

Convert from Floating point number to binary 1. Convert the integer part to binary 2. ‰Convert the fraction to binary 3. ‰Put a decimal point between the two parts

Convert from Floating point number to binary Example Transform the fraction to binary Answer: Write the fraction at the left corner. Multiply the number continuously by 2 and extract the integer part as the binary digit. Stop when the number is 0.0. fraction binary   1.50  1.0 

Convert from Floating point number to binary Example Transform the fraction 0.4 to a binary of 6 bits. Answer: Write the fraction at the left cornet. Multiply the number continuously by 2 and extract the integer part as the binary digit. You can never get the exact binary representation. Stop when you have 6 bits fraction binary 0.4  0.8  1.6  1.2  0.4  0.8 

NORMALIZATION

Normalization A fraction is normalized so that operations are simpler Normalization: the moving of the decimal point so that there is only one 1 to the left of the decimal point.

Normalization NormaliazedMoveOriginal Number x x x x

Normalization After the number is normalized we store 3 pieces of information about it: SIGN EXPONENT MANTISSA Example : x SIGNEXPONENTMANTISSA

IEEE standard for floating point representation

Single-Precesion Representation The procedure of storing a normalized floating point number using single precession format is as follow: 1. Store the sign as 0 (positive) or 1 (negative) 2. Store the exponent (power of 2) as Excess_ Store the mantissa as unsigned integer

EXAMPLE  Show the representation of the normalized number x ANSWER: The sign is positive. The Excess_127 representation of the exponent is 133. You add extra 0s on the right to make it 23 bits. The number in memory is stored as: SIGNEXPONENTMANTISSA

Example of floating point representation MantissaExponentSignNumber x x x

Floating point Interpretation for single precision the following procedure interprets a 32-bit floating-point number stored in memory 1. Use the leftmost bit as the sign 2. Change the next 8 bit to decimal and subtract 127 from it. (this is the exponent) 3. Add 1 and a decimal point to the next 23 bits (ignore any extra 0’s in the right) 4. Move the decimal point to the correct position using the value of the exponent 5. Change the whole part to decimal 6. Change the fraction part to decimal 7. Combine the whole and the fraction parts

Example Interpret the following 32-bit floating-point number ANSWER : The sign is negative. The exponent is –3 (124 –127). The number after normalization is x