Computer Organization 1 Data Representation Negative Integers.

Slides:



Advertisements
Similar presentations
Integers. Integer Storage Since Binary consists only of 0s and 1s, we can’t use a negative sign ( - ) for integers. Instead, the Most Significant Bit.
Advertisements

2’s Complement Arithmetic (remember it’s a fixed length system)
James Tam Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer? How.
James Tam Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer? How.
James Tam Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer?
James Tam Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer? How.
James Tam Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer? How.
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Representations Example: Numbers –145 –CVL – –91 –
Assembly Language and Computer Architecture Using C++ and Java
Agenda Shortcuts converting among numbering systems –Binary to Hex / Hex to Binary –Binary to Octal / Octal to Binary Signed and unsigned binary numbers.
Signed Numbers Up till now we've been concentrating on unsigned numbers. In real life we have to represent signed numbers ( like: -12, -45, 78). The difference.
Assembly Language and Computer Architecture Using C++ and Java
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
Complements: different approaches for representing negative numbers
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
Signed Numbers CS208. Signed Numbers Until now we've been concentrating on unsigned numbers. In real life we also need to be able represent signed numbers.
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.
Introduction to Number Systems
COMP201 Computer Systems Number Representation. Number Representation Introduction Number Systems Integer Representations Examples  Englander Chapter.
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
3. Representing Integer Data
NEGATIVE BINARY NUMBER – Digital Circuit 1 Choopan Rattanapoka.
Binary Representation and Computer Arithmetic
Computer Systems 1 Fundamentals of Computing Negative Binary.
Binary numbers and arithmetic. ADDITION Addition (decimal)
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
The Binary Number System
Data Representation Number Systems.
Data Representation – Binary Numbers
Representing Integer Data Book : Chapter ( Subject has no point !! ) A99ACF.
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 & Lewis Chapter 3 Data Representation. Data and computers Everything inside a computer is stored as patterns of 0s and 1s Numbers, text, audio, video,
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
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.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Positional Number Systems
ECE2030 Introduction to Computer Engineering Lecture 2: Number System Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Tech.
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.
COMP201 Computer Systems Floating Point Numbers. Floating Point Numbers  Representations considered so far have a limited range dependent on the number.
THE BINARY SYSTEM.
By Jariya Phongsai A two's-complement system is a system in which negative numbers are represented by the two's complement of the absolute value; this.
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Information Representation: Negative Integer Representation.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
James Tam Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer? How.
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.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.
Binary Arithmetic James A. Rome Tennessee Governor's Academy August 2010.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Advanced Binary b. describe and use two’s complement and sign and magnitude to represent negative integers; c. perform integer binary arithmetic, that.
Lecture 4: Digital Systems & Binary Numbers (4)
Representing Positive and Negative Numbers
Integer Real Numbers Character Boolean Memory Address CPU Data Types
Computer Science 210 Computer Organization
Unit 18: Computational Thinking
How are negative and rational numbers represented on the computer?
CPS120: Introduction to Computer Science
Decimal and binary representation systems
Binary to Decimal Conversion
Two’s Complement & Binary Arithmetic
Presentation transcript:

Computer Organization 1 Data Representation Negative Integers

There are 4 different ways of representing negative binary integers in computers: Signed Magnitude Ones Complement Twos Complement Excess (Biased) representation

Signed Magnitude (Sign and Magnitude) Similar to the way we write numbers – we may precede the number with a sign. We write minus 12 as -12. That is, the sign is a symbol in the number. In binary signed magnitude representation in computers, the leftmost bit is used for a sign, 0 for + and 1 for minus. The remaining bits contain the absolute magnitude of the number.

Signed Magnitude Integers in one byte signed magnitude representation: + 12 = = the negative is formed by changing the MSB to 1. Note that there are both +ve and –ve representations of 0: and Remember that there are 256 permutations of 0 and 1 in an 8-bit byte. signed magnitude can represent only 255 integers, because of the two representations for zero.

Ones Complement Ones complement is trivial – to change from positive to negative or vice versa - convert all 1s to 0s, and all 0s to 1s. Thus, in one byte ones complement representation, + 12 = =

Ones Complement That is, the negative is formed by complementing, or ‘flipping’ the bits. Note again, that there are both +ve and –ve representations of 0: and Since there are 256 permutations of 0 and 1 in a byte, with ones complement we can represent only 255 integers in a byte, because of the two representations for zero.

One Complement

Ones complement arithmetic can be complex in some cases Add –12 and + 13 in ones complement byte:

Twos Complement Integers The negative in 2s complement is formed in a similar way to ones complement: flip all the bits, then add 1. (If the addition results in a carry out from the MSB, discard the carry out. )

Twos Complement Integers Using 3 bit word (8 representations):

Twos Complement Byte – Only one zero representation

Excess (Biased) representation In excess or biased notation, the number is treated as unsigned, but is shifted in value by subtracting the bias from it. Eg one byte Excess 128 (The bias to be subtracted is 128) Excess 128 Decimal (2s complement)

Excess (biased) Notation Excess 128 Decimal 2s complement …. … …

Excess (biased) Notation Excess 128 Decimal 2s complement …. … … We see a ‘continuous’ change for values through –2, -1, 0 1, 2, 3, as we add 1 to each binary value. Whereas in twos complement, the values ‘jump’ from 127 to minus 128, and then reduce by 1 in absolute values all the way down to –1 for the biggest (in pure binary) binary value.

Excess (biased) Notation Excess 128 Decimal 2s complement We see from the above that excess notation provides for easier comparisons of bit patterns, because of the continuity, that is, is ‘bigger’ than in excess 128 but not in twos complement.

Excess byte Notation To create an excess 128 byte value: +12 = = = This represents 140 ( ) in pure binary. Another example: -12 = = ? = 116 =

Summary There are 4 ways to represent negative and positive integers in computers; main methods in common use now are Twos Complement and Excess notation. Twos complement: Given binary x, to find –x, flip the bits and add 1. Given binary -x, to find x, flip the bits and add 1. Excess y: Take decimal x, add y and find the pure binary equivalent. Given excess binary no. z, subtract y and convert the resulting twos complement number to decimal.