©Brooks/Cole, 2003 Chapter 3 Number Representation.

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.
Chapter 2: Data Representation
Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 2: Data Representation.
©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
Digital Fundamentals Floyd Chapter 2 Tenth Edition
Assembly Language and Computer Architecture Using C++ and Java
Chapter 5 Floating Point Numbers. Real Numbers l Floating point representation is used whenever the number to be represented is outside the range of integer.
1 Lecture 3 Bit Operations Floating Point – 32 bits or 64 bits 1.
Signed Numbers.
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.
Floating Point Numbers
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
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.
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.
Binary Number Systems.
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
Chapter 5 Data representation.
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
The Binary Number System
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
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.
Data Representation – Binary Numbers
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.
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
Chapter 1 Data Storage(3) Yonsei University 1 st Semester, 2015 Sanghyun Park.
IT253: Computer Organization
Studies in Big Data 4 Weng-Long Chang Athanasios V. Vasilakos MolecularComputing Towards a Novel Computing Architecture for Complex Problem Solving.
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.
Data Representation.
Number Systems Spring Semester 2013Programming and Data Structure1.
9.4 FLOATING-POINT REPRESENTATION
Representation of Data Ma King Man. Reference Text Book: Volume 2 Notes: Chapter 19.
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.
CSC 221 Computer Organization and Assembly Language
Number Representation
©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.
1 Representation of Data within the Computer Oct., 1999(Revised 2001 Oct)
Computer Organization and Design Information Encoding II Montek Singh Wed, Aug 29, 2012 Lecture 3.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Floating Point Numbers
CS2100 Computer Organisation
Chapter 4 Operations on Bits.
Integer Real Numbers Character Boolean Memory Address CPU Data Types
Data Structures Mohammed Thajeel To the second year students
Data Representation Data Types Complements Fixed Point Representation
Number Representation
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:

©Brooks/Cole, 2003 Chapter 3 Number Representation

©Brooks/Cole, 2003 It is not efficient to represent numbers in the same way as symbols representation. For example representing as symbols using ASCII requires 5 bytes each representing a digit. And it is obvious That as the number of digits increases the number of bytes Increases. Therefore we need a more efficient way to represent numbers. Number representation

©Brooks/Cole, 2003 DECIMALANDBINARYDECIMALANDBINARY 3.1

Figure 3-1 Decimal system

©Brooks/Cole, 2003 Figure 3-2 Binary system

©Brooks/Cole, 2003 CONVERSIONCONVERSION 3.2

Figure 3-3 Binary to decimal conversion

©Brooks/Cole, 2003 Figure 3-4 Decimal to binary conversion

©Brooks/Cole, 2003 INTEGERREPRESENTATIONINTEGERREPRESENTATION 3.4

Figure 3-5 Range of integers Integers are whole numbers without a fraction. For example,134 is an integer but is not. Integers can be positive and negative.

©Brooks/Cole, 2003 Figure 3-6 Taxonomy of integers

©Brooks/Cole, 2003 Unsigned integers # of Bits # of Bits Range Range ,535 The maximum unsigned integer depends on the number of bits allocated in the computer to store an unsigned integer. For N number of bits, the maximum integer to be represented is (2 N -1)

©Brooks/Cole, 2003 Table 3.2 Example of storing unsigned integers in two different computers two different computers Decimal Decimal ,760 1,245,678 8-bit allocation overflow 16-bit allocation overflow

©Brooks/Cole, 2003 Applications (unsigned) Counting Addressing

©Brooks/Cole, 2003 Signed integer: 1.Sign and magnitude In this format one bit is needed to represent the sign of integer number (0 for positive integer and 1 for negative) For N number of bits allocated for the signed number, the range of integer numbers is given by: -(2 N-1 – 1) …… (2 N-1 -1)

©Brooks/Cole, 2003 Sign-and-magnitude integers # of Bits # of Bits  127  0   0   ,147,483,647 Range

©Brooks/Cole, 2003 Sign and Magnitude Representation 1.Convert the magnitude to binary 2.Add 0s to the left to make the total number of bits N-1. 3.If number is positive add 0 to the left; if number is negative add 1 to the left

©Brooks/Cole, 2003 Table 3.4 Example of storing sign-and-magnitude integers in two computers Decimal Decimal ,760 8-bit allocation overflow 16-bit allocation

©Brooks/Cole, 2003 Sign and Magnitude Interpertation 1.Ignore the first (liftmost) bit, 2.Change the following bits to decimal. 3.Attach + or – sign based on the left most bit.

©Brooks/Cole, 2003 Advantages, Disadvantages, and Application (sign and magnitude) 1.Disadvantages: two zeros 2.Advantages: easy transformation 3.Application: data communication.

©Brooks/Cole, 2003 Signed integer: 2. One’s Complement In this format the negative number is the complement of the positive number, for example -7 is represented as the binary complement of +7. The number’s complement is obtained by changing all 0s to 1s and all 1s to 0s. The left most digit is assigned for the number’s sign (0 for positive, 1 for negative).

©Brooks/Cole, 2003 Range of one’s complement integers # of Bits # of Bits  127  0   0   ,147,483,647 Range For N number of bits allocated for the signed number, the range of integer numbers is given by: -(2 N-1 – 1) …… (2 N-1 -1)

©Brooks/Cole, 2003 One’s Complements Representation 1.Convert the magnitude to binary 2.If number is positive, add 0s to the left to make the total number of bits N. 3.If number is negative add complement the positive representation (step 2)

©Brooks/Cole, 2003 Table 3.6 Example of storing one’s complement integers in two different computers Decimal Decimal       8-bit allocation overflow 16-bit allocation

©Brooks/Cole, 2003 One’s Complement Interpretation If the leftmost 0 (positive number) 1.Change the entire number to decimal 2.Put (+) in front of the number. If the leftmost is 1 (negative number) 1.Complement the entire number. 2.Change the entire number to decimal. 3.Put (-) in front of the number

©Brooks/Cole, 2003 Disadvantages, and Application (One’s Complement) 1.Disadvantages: two zeros 2.Application: error detection and correction.

©Brooks/Cole, 2003 Signed integer: 3. Two’s Complement Two’s complement solves the problems of two zeros. Two’s complement is widely used representation of integers today. For N number of bits allocated for the signed number, the range of integer numbers is given by: -(2 N-1 ) …… (2 N-1 -1) The left most digit shows the number’s sign (0 for positive, 1 for negative).

©Brooks/Cole, 2003 Range of two’s complement integers # of Bits  128  32,768  , ,147,483,647 Range

©Brooks/Cole, 2003 Two’s Complements Representation 1.Convert the magnitude to binary 2.Add 0s to the left to make the total number of bits equal to N. 3.If the number is positive no action is needed. If the number is negative, complement after the first 1 from the right of the positive representation.

©Brooks/Cole, 2003 Table 3.8 Example of storing two’s complement integers in two different computers Decimal Decimal       8-bit allocation overflow 16-bit allocation

©Brooks/Cole, 2003 Two’s Complement Interpretation If the leftmost 0 (positive number) 1.Change the entire number to decimal 2.Put (+) in front of the number. If the leftmost is 1 (negative number) 1.Complement after the first 1 from the right. 2.Change the entire number to decimal. 3.Put (-) in front of the number

©Brooks/Cole, 2003 Two’s complement can be achieved by reversing all bits except the rightmost bits up to the first 1 (inclusive). If you two’s complement a positive number, you get the corresponding negative number. If you two’s complement a negative number, you get the corresponding positive number. If you two’s complement a number twice, you get the original number. Note:

©Brooks/Cole, 2003 Application (Tow’s Complement) Two’s complement is used in today’s computer

©Brooks/Cole, 2003 Table 3.9 Summary of integer representation Contents of Memory Contents of Memory Unsigned Sign-and- Magnitude  One’s Complement  Two’s Complement 

©Brooks/Cole, 2003 Signed integer: Excess System Excess system is used to store signed integer numbers in computer. In Excess system a positive number called magic number is used for this format. The magic number is either 2 N-1 or 2 N For example if N = 8 the magic number is either 128 (called excess_128) or 127 (called excess_127)

©Brooks/Cole, 2003 Excess System Representation 1.Add the magic number to the integer. 2.Change the result to binary 3.Add 0s to the left to make total number of bits equal to N.

©Brooks/Cole, 2003 Excess System Interpretation 1.Change the number to decimal 2.Subtract the magic number form the integer.

©Brooks/Cole, 2003 Excess System Range 1.For Magic number equal to 2 N-1 the range is - (2 N-1 )….. +(2 N-1 -1) # of Bits  128  32,768  , ,147,483,647 Range

©Brooks/Cole, 2003 Excess System Range 1.For Magic number equal to 2 N-1 -1 the range is - (2 N-1 -1)….. +(2 N-1 ) # of Bits  127  32,767  , ,147,483,648 Range

©Brooks/Cole, 2003 Advantages, Disadvantages and Application (Excess System) Advantages: Easy transformation. Disadvantages: operation on excess system is very complicated. Applications: used in storing exponential values of fraction.

©Brooks/Cole, 2003 FLOATING-POINTREPRESENTATIONFLOATING-POINTREPRESENTATION

Floating Point Number Floating point number is a number containing an integer and a fraction For example in floating point number , the integer part is 21 and the fraction is 0.345

©Brooks/Cole, 2003 Floating Point Representation 1.Convert the integer part to binary 2.Convert the fraction part to binary by repetitively multiply the fraction part by 2. The binary digit is the integer part of the result of multiplication. Stop whenever the fraction part becomes 0 or when you reach the maximum number of bits you can use. 3.Put a decimal point between the two parts.

©Brooks/Cole, 2003 Figure 3-7 Changing fractions to binary

©Brooks/Cole, 2003 Floating Point Interpretation 1.Convert the integer part to decimal 2.Convert the fraction part to decimal by: 1. multiplying each digit by its weight. 2.Add alltogether 3.Put a decimal point between the two parts.

©Brooks/Cole, 2003 Figure 3-3 Binary floating to decimal conversion

©Brooks/Cole, 2003 Normalization Normalization is a standard way to write floating point binary number. Normalization is achieved by moving the decimal point so that there is only one 1 to the left of it. To indicate how many digits the decimal point has moved, multiply the number by 2 e which indicates the direction and number of digits moved. If : –e is positive, decimal point moved to the left –e is negative, decimal point moved to the right

©Brooks/Cole, 2003 Table 3.10 Example of normalization Original Number Original Number Move Move  6  2 6  3  Original Number Original Number     Normalized    x     x    x     x 

©Brooks/Cole, 2003 Sign, Exponent and Mantissa After the number normalization you store only three pieces of information about the number: sign, exponent and mantissa. –Sign is the number sign (stored in 1 bit) –Exponent (power of 2) shows direction and magnitude of decimal point movement. –Mantissa is the bits to the right of the decimal point.

©Brooks/Cole, 2003 Normalization (example) For the number: Normalized Number: x Sign: + Exponent: 6 Mantissa:

©Brooks/Cole, 2003 Figure 3-8 IEEE standards for floating-point representation

©Brooks/Cole, 2003 Single Precision Representation Store the sign as 0 (positive) or 1 (negative) Store the exponent (power of 2) as Excess_127 Store the mantissa as an unsigned integer. Add 0s to the right of the mantissa to make the total number of mantissa bits equal to 23

©Brooks/Cole, 2003 Table 3.11 Example of floating-point representation Sign Sign Mantissa Number x x x Exponent Exponent

©Brooks/Cole, 2003 Floating point Interpretation (Single Precision) The sign is the leftmost bit Change the next 8 bits to decimal and subtract 127 from it. add 1 to the left of the mantissa (next 23 bits) and discard the zeros to the left of it. Move the decimal point to its original position. Convert the integer and fraction to decimal

©Brooks/Cole, 2003 Hexadecimal Notation Floating point numbers can be written using hexadecimal notation. For example : , using IEEE standards is And in Hexadecimal notation: x42A39000