Data Representation - Part I. Representing Numbers Choosing an appropriate representation is a critical decision a computer designer has to make The chosen.

Slides:



Advertisements
Similar presentations
Representing Numbers: Integers
Advertisements

Topics covered: Floating point arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
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.
DATA REPRESENTATION Y. Colette Lemard February
COE 202: Digital Logic Design Signed Numbers
Representations Example: Numbers –145 –CVL – –91 –
Assembly Language and Computer Architecture Using C++ and Java
Number Systems Standard positional representation of numbers:
1 Lecture 3 Bit Operations Floating Point – 32 bits or 64 bits 1.
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.
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
CSE 378 Floating-point1 How to represent real numbers In decimal scientific notation –sign –fraction –base (i.e., 10) to some power Most of the time, usual.
Number Representation (1) Fall 2005 Lecture 12: Number Representation Integers and Computer Arithmetic.
Two’s Complement 1.As an action: (Assume the starting value is 1011) 1.Flip the bits from the starting value => Add one to get the answer.
Review Binary Basic Conversion Binary Decimal
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…
Number Systems Lecture 02.
Binary Number Systems.
School of Computer Science G51CSA 1 Computer Arithmetic.
Binary Representation and Computer Arithmetic
Computer Systems 1 Fundamentals of Computing Negative Binary.
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
Lecture 5.
1 Arithmetic and Logical Operations - Part II. Unsigned Numbers Addition in unsigned numbers is the same regardless of the base. Given a pair of bit sequences.
Number Systems - Part II
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?
Data Representation – Binary 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.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Information Representation: Negative and Floating Point.
Computer Science 111 Fundamentals of Programming I Number Systems.
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.
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 29, 2004 Lecture Number: 26.
Complement Numbers. Outline  Negative Numbers Representation  Sign-and-magnitude  1s Complement  2s Complement  Comparison of Sign-and-Magnitude.
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 20, 2004 Lecture Number: 23.
Calculating Two’s Complement. The two's complement of a binary number is defined as the value obtained by subtracting the number from a large power of.
Representation of Data Ma King Man. Reference Text Book: Volume 2 Notes: Chapter 19.
Integer Representation for People Computer Organization and Assembly Language: Module 3.
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.
Number Representation
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
Operations on Bits Arithmetic Operations Logic Operations
Fractions in Binary.
CDP ECE Spring 2000 ECE 291 Spring 2000 Lecture 2: Number Systems & x86 Instructions Constantine D. Polychronopoulos Professor, ECE Office: 463.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Digital Representations ME 4611 Binary Representation Only two states (0 and 1) Easy to implement electronically %0= (0) 10 %1= (1) 10 %10= (2) 10 %11=
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.
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.
Integer Operations Computer Organization and Assembly Language: Module 5.
Computer Organization 1 Data Representation Negative Integers.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
ECE 3110: Introduction to Digital Systems Signed Number Conversions and operations.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Representing Positive and Negative Numbers
Floating Point Representations
Computer Architecture & Operations I
Numbers representations
Chapter3 Fixed Point Representation
Presentation transcript:

Data Representation - Part I

Representing Numbers Choosing an appropriate representation is a critical decision a computer designer has to make The chosen representation must allow for efficient execution of primitive operations For general-purpose computers, the representation must allow efficient algorithms for (1) addition of two integers (2) determination of additive inverse

With a sequence of N bits, there are 2 N unique representations Each memory cell can hold N bits The size of the memory cell determines the number of unique values that can be represented The cost of performing operations also increases as the size of the memory cell increases It is reasonable to select a memory cell size such that numbers that are frequently used are represented

Binary Representation The binary, weighted positional notation is the natural way to represent non-negative numbers SAL and MAL number the bits from right to left, i.e., beginning with 0 as the least significant digit

Little-Endian vs. Big-Endian Numbering the bits from right to left, beginning with zero is called Little Endian byte order. Intel 80x86 and DECstation 3100 use the Little Endian byte ordering. Numbering the bits from left to right, beginning with zero is called Big Endian byte order. SunSparc and Macintosh use the Big- Endian byte ordering.

Representation of Integers Unsigned Integer Representation Sign Magnitude Complement Representation Biased Representation Sign Extension

Unsigned Integer Representation The representation of a non-negative integer using binary, weighted positional notation is called unsigned integer representation Given n bits, it is possible to represent the range of values from 0 to 2 n - 1 For example an 8-bit representation would allow representations that range 0 to 255

Sign Magnitude An extra bit in the most significant position is designated as the sign bit which is to the left of an unsigned integer. The unsigned integer is the magnitude. A 0 in the sign bit means positive, and a 1 means negative xxx xxxx x

Given an n+1 -bit sign magnitude number the range of values that it can represent is -(2 n -1) to +(2 n -1) Sign magnitude representation associates a sign bit with a magnitude that represents zero, thus it has two distinct representation of zero: and sign bit magnitude

Complement Representation For positive integers, the representation is the same as for sign magnitude For negative numbers, a large bias is added to all negative numbers, creating positive numbers in unsigned representation The bias is chosen so that any negative number representable appears as if it were larger than the largest positive number representable

One’s Complement For positive numbers, the representation is the same as for unsigned integers where the most significant bit is always zero The additive inverse of a one’s complement representation is found by inverting each bit. Inverting each bit is also called taking the one’s complement

Example (3) (-3) (-23) (23) (0) (0) Note: There are two representations of zero

Two’s complement The additive inverse of a two’s complement integer can be obtained by adding 1 to its one’s complement The two’s complement representation for a negative number is the additive inverse of its positive representation An advantage of two’s complement is that there is only one representation for zero

Example (17) (-24) (-17) (24) take the 1’s complement

In two’s complement, one more negative value than positive value is represented - the most negative number has no additive inverse within a fixed precision. For example, has no additive inverse for 8-bit precision. Taking the two’s complement will yield which seems its own additive inverse. This is incorrect and is an example of an overflow. Note that computing the additive inverse is a mathematical operation. Taking the complement is an operation on the representation.

Biased Representation If the unsigned representation includes integers from 0 to M, then subtracting approximately M/2 from the unsigned interpretation would shift the range from -(M/2) to +(M/2) If a sequence has a value N when interpreted as an unsigned integer, it has a value N-bias interpreted as a biased number Usually the bias is either 2 n or 2 n -1 for an (n+1) bit representation

Example 9.3 Assume a 3-bit representation. A possible bias is 2 n-1, which is 4. The following is a 3-bit representation with a bias of 4. bit patterninteger represented (in decimal)

Example 9.4 Given , what is it’s value in a biased-127 representation. Assume an 8-bit representation. The value of the unsigned integer: =6 10 Its value in biased-127 is: = -121

Sign Extension For integer representations, the sizes are commonly 8, 16, 32 and 64. It is occasionally necessary to convert an integer representation from one size to another, e.g., from 8 bits to 32 bits. The point is to maintain the same value while changing the size of the representation

Sign Extension - Unsigned Place the original integer into the least significant portion and stuff the remaining positions with 0 ’s. xxxxxxxx xxxxxxxx 8 bits 16 bits

Sign Extension - Signed The sign bit of the smaller representation is placed into the sign bit of the larger representation The magnitude is put into the least significant portion and all remaining positions are stuffed with 0 ’s. sxxxxxxx s xxxxxxx

Sign Extension - complement For positive number, a 0 is used to stuff the remaining positions. For negative number, a 1 is used to stuff the remaining positions. 0xxxxxxx xxxxxxx 1xxxxxxx xxxxxxx The original number is placed into the least significant portion The original number is placed into the least significant portion