Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Information Representation: Negative Integer 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

Sample Test 1 Question. A pattern of binary digits can be interpreted in several different ways. Show how the pattern translates using each of.
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.
COE 202: Digital Logic Design Signed Numbers
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
1 Lecture 3 Bit Operations Floating Point – 32 bits or 64 bits 1.
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.
Binary Number Systems.
School of Computer Science G51CSA 1 Computer Arithmetic.
Binary numbers and arithmetic. ADDITION Addition (decimal)
Computer Organization & Programming Chapter2 Number Representation and Logic Operations.
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?
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.
Computer Architecture
Data Representation - Part I. Representing Numbers Choosing an appropriate representation is a critical decision a computer designer has to make The chosen.
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.
Number Systems Spring Semester 2013Programming and Data Structure1.
CSE 111 Representing Numeric Data in a Computer Slides adapted from Dr. Kris Schindler.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
10-Sep Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Sept Representing Information in Computers:  numbers: counting numbers,
The Teacher CP4 Binary and all that… CP4 Revision.
Number Representation
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Information Representation: Floating Point Representation.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Ch3a- 2 EE/CS/CPE Computer Organization  Seattle Pacific University Crunching Numbers Topics we need to explore Representing numbers on a computer.
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.6 Instructor: Lin Chen Sept 2013.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
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=
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Information Representation: Positive Integers Dale Roberts,
Negative Integers Unsigned binary representation can not be used to represent negative numbers. With paper and pencil arithmetic, a number is made negative.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Computer Organization 1 Data Representation Negative Integers.
Data Representation COE 301 Computer Organization Dr. Muhamed Mudawar
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
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.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
FLOATING-POINT NUMBER REPRESENTATION
Department of Computer Science Georgia State University
Fundamentals of Computer Science
Data Representation COE 308 Computer Architecture
Programming and Data Structure
Data Representation ICS 233
Data Representation.
Negative Integers Unsigned binary representation can not be used to represent negative numbers. With paper and pencil arithmetic, a number is made negative.
Introduction To Computer Science
A First C Program (mixing datatypes)
A First C Program (mixing datatypes)
Binary numbers and arithmetic
CS1010 Programming Methodology
Data Structures Mohammed Thajeel To the second year students
TAO1221 COMPUTER ARCHITECTURE AND ORGANIZATION LAB 6
Data Representation COE 301 Computer Organization
Negative Integer Representation
Chapter 3 DataStorage Foundations of Computer Science ã Cengage Learning.
Data Representation ICS 233
Lecture No.5.
OBJECTIVES After reading this chapter, the reader should be able to :
Data Representation COE 308 Computer Architecture
Presentation transcript:

Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Information Representation: Negative Integer Representation

Dale Roberts Negative Numbers in Binary Four different representation schemes are used for negative numbers 1. Signed Magnitude Left most bit (LMB) is the sign bit : 0  positive (+) 1  negative (-) Remaining bits hold absolute magnitude Example: 2 10  b  b Q: = ? = ? Try, b =-4 10

Dale Roberts 1’s Complement 2.One’s Complement – –Left most bit is the sign bit : 0  positive (+) 1  negative (-) – –The magnitude is Complemented Example: 2 10  b  b Exercise: try using 1’s Complement Q: = ? = ? = ? Solution: 4 10 = b = b 1

Dale Roberts 2’s Complement 3.2’s Complement Sign bit same as above Magnitude is Complemented first and a “1” is added to the Complemented digits Example: 2 10  b 1’s Complement  b  b 7 10  1’s Complement   Exercise: try using 2’s Complement b b b

Dale Roberts 2’s Complement 7 10 = b 3 10 = b 1’s complement b 2’s complement b  (-3)  Example: 7+(-3) [hint]: A – B = A + (~B) carry ignore   4 10

Dale Roberts Three Representation of Signed Integer

Dale Roberts Negative Numbers in Binary (cont.) 4. Excess Representation – – For a given fixed number of bits the range is remapped such that roughly half the numbers are negative and half are positive. Example: (as left) Excess – 8 notation for 4 bit numbers Binary value = 8 + excess-8 value MSB can be used as a sign bit, but If MSB =1, positive number If MSB =0, negative number Excess Representation is also called bias Numbers Binary Value Notation Excess – 8 Value

Dale Roberts Fundamental Data Types 2 byte unsigned (Default type is int ) 2 byte int (  0 D ) (  1 D ) (  2 D ) … (  D  ) (  D  2 15 ) … (  2 16 –1) (  D  ) (  D  ) … (  - 2 D ) (  - 1 D ) (  0 D ) (  1 D ) (  2 D ) … (  D  ) With vs. without using sign bit With vs. without using sign bit For a 16 bit binary pattern:

Dale Roberts Fundamental Data Types Four Data Types in C Four Data Types in C (assume 2’s complement, byte machine) Data Type Abbreviation Size (byte) Range char ~ 127 unsigned char10 ~ 255 int 2 or ~ or ~ unsigned int unsigned 2 or 40 ~ or 0 ~ short int short ~ unsigned short int unsigned short 20 ~ long int long ~ unsigned long int unsigned long 40 ~ float4 double8 Note:2 7 = 128, 2 15 =32768, 2 15 = Complex and double complex are not available

Dale Roberts Acknowledgements These slides where originally prepared by Dr. Jeffrey Huang, updated by Dale Roberts.