Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

Similar documents
Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

Introduction to Computers and Programming. Numeric Values

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

World Inside a Computer is Binary

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

Number System. Introduction. Decimal Numbers

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

COMP2611: Computer Organization. Data Representation

UNIT 7A Data Representation: Numbers and Text. Digital Data

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

MACHINE LEVEL REPRESENTATION OF DATA

Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

Chapter 10 Binary Arithmetics

MC1601 Computer Organization

Integers. N = sum (b i * 2 i ) where b i = 0 or 1. This is called unsigned binary representation. i = 31. i = 0

CS & IT Conversions. Magnitude 10,000 1,

BINARY SYSTEM. Binary system is used in digital systems because it is:

Chapter 3: Arithmetic for Computers

CHW 261: Logic Design

Numeric Encodings Prof. James L. Frankel Harvard University

Chapter 1 Review of Number Systems

Binary Codes. Dr. Mudathir A. Fagiri

SE311: Design of Digital Systems

M1 Computers and Data

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

COMP Overview of Tutorial #2

The type of all data used in a C (or C++) program must be specified

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

CHAPTER 5: Representing Numerical Data

CS101 Lecture 04: Binary Arithmetic

CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

The type of all data used in a C++ program must be specified

EE 109 Unit 6 Binary Arithmetic

Chapter 1. Digital Systems and Binary Numbers

Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction

Chapter 3: part 3 Binary Subtraction

Module 2: Computer Arithmetic

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

INF2270 Spring Philipp Häfliger. Lecture 4: Signed Binaries and Arithmetic

Inf2C - Computer Systems Lecture 2 Data Representation

SIGNED AND UNSIGNED SYSTEMS

CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29

Introduction to Computer Science-103. Midterm

Chapter 2 Bits, Data Types, and Operations

CO212 Lecture 10: Arithmetic & Logical Unit

Computer Organization

Numerical Representations On The Computer: Negative And Rational Numbers

Digital Fundamentals

Computer (Literacy) Skills. Number representations and memory. Lubomír Bulej KDSS MFF UK

E40M. Binary Numbers, Codes. M. Horowitz, J. Plummer, R. Howe 1

Arithmetic and Logical Operations

Number Systems Base r

Operations On Data CHAPTER 4. (Solutions to Odd-Numbered Problems) Review Questions

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

Data Representation and Binary Arithmetic. Lecture 2

Chapter 4. Operations on Data

CS 31: Intro to Systems Binary Arithmetic. Kevin Webb Swarthmore College January 26, 2016

Chapter 2 Bits, Data Types, and Operations

FLOATING POINT NUMBERS

Number Systems (2.1.1)

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

Computer Arithmetic. L. Liu Department of Computer Science, ETH Zürich Fall semester, Reconfigurable Computing Systems ( L) Fall 2012

DIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) COURSE / CODE NUMBER SYSTEM

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Lecture 2: Number Systems

CS 261 Fall Mike Lam, Professor Integer Encodings

Chapter 2 Bits, Data Types, and Operations

4/8/17. Admin. Assignment 5 BINARY. David Kauchak CS 52 Spring 2017

Korea University of Technology and Education

8/27/2016. ECE 120: Introduction to Computing. Graphical Illustration of Modular Arithmetic. Representations Must be Unambiguous

Number Systems CHAPTER Positional Number Systems

Number Systems. Both numbers are positive

CMPSCI 145 MIDTERM #1 Solution Key. SPRING 2017 March 3, 2017 Professor William T. Verts

Digital Systems and Binary Numbers

Advanced Computer Architecture-CS501


CS 64 Week 1 Lecture 1. Kyle Dewey

EE292: Fundamentals of ECE

3.5 Floating Point: Overview

T02 Tutorial Slides for Week 2

N.B. These pastpapers may rely on the knowledge gained from the previous chapters.

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

Computer Sc. & IT. Digital Logic. Computer Sciencee & Information Technology. 20 Rank under AIR 100. Postal Correspondence

Numerical Representations On The Computer: Negative And Rational Numbers

Numbering systems. Dr Abu Arqoub

DATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes. Error Detection Codes

Chapter 4: Data Representations

Transcription:

Basic Definition REPRESENTING INTEGER DATA Englander Ch. 4 An integer is a number which has no fractional part. Examples: -2022-213 0 1 514 323434565232 Unsigned and -Coded Decimal BCD: -Coded Decimal Each decimal digit individually converted to Each decimal digit individually converted to binary Requires 4 bits per digit 8-bit location hold 2 BCD digits 00 to 99 68 10 0110 1000 BCD Hexa: 4 bits can hold 16 values, 0 to F A to F not used in BCD 1

Ranges for Data Formats In General (binary) No. of bits 1 2 3 4 5 6 7 8 9 16 24 Etc. 0 1 0 3 0 7 0 15 0 31 0 63 0 127 0 255 0 511 0-65,535 0 16,777,215 BCD 0 9 0 99 0 9999 0 999999 ASCII 0 9 0 99 0 999 No. of bits Min Max n 0 2 n -1 Remember!! Signed Integers Sign-Magnitude Previous examples were for unsigned integers (positive values only!) Must also have a mechanism to represent signed integers (positive and negative values!) Eg,-5 E.g., 10 =? 2 Two common schemes: 1) sign-magnitude 2) two s complement Extra bit on left to represent sign 0 = positive value 1 = negative value E.g., 6-bit sign-magnitude representation of +5 and 5: +5: 0 0 0 1 0 1-5: 1 0 0 1 0 1 + 5-5 2

Ranges (revisited) Unsigned Sign-magnitude No. of bits Min Max Min Max 1 0 1 2 0 3-1 1 3 0 7-3 3 4 0 15-7 7 5 0 31-15 15 6 0 63-31 31 Etc. In General (revisited) Unsigned Sign-magnitude No. of bits Min Max Min Max n 0 2 n - 1 -(2 n-1-1) 2 n-1-1 Difficulties with Sign-Magnitude Two representations of zero 0: 000000 0: 100000 Arithmetic is awkward! One s complement Principle: Invert bits (0 1 and 1 0) 6: 000110 Range -6: 111001 3

Add / Sub in 1 s complement Overflow Overflow sign of result sign both operands Two s Complement Most common scheme of representing negative numbers in computers Affords natural arithmetic ti (no special rules!) To represent a negative number in 2 s complement notation 1. Decide upon the number of bits (n) 2. Find the binary representation of the positive value in n-bits 3. Flip all the bits (change 1 s to 0 s and vice versa) 4. Add 1 Learn! 4

Two s complement representation Two s Complement Example Represent 5 in binary using 2 s complement notation 1. Decide on the number of bits, for example: 6 2. Find the binary representation of the positive (5) value in 6 bits 000101 +5 3. Flip all the bits 111010 4. Add 1 111010 + 1 111011-5 Sign Bit In 2 s complement notation, the MSB is the sign bit (as with sign-magnitude notation) 0 = positive value 1 = negative value +5: 0 0 0 1 0 1-5: 1 1 1 0 1 1 + 5 -? (previous slide) Complementary Notation Conversions between positive and negative numbers are easy For binary (base 2) 2 s C + - 2 s C 5

Example +5 0 0 0 1 0 1 Detail for -20 11101100 2 s C -5 2 sc 2s 1 1 1 0 1 0 + 1 1 1 1 0 1 1 0 0 0 1 0 0 + 1-20 10 : Positive Vl Value = 00010100 Flip : (One s complement) 11101011 Add 1: + 1 11101100 +5 0 0 0 1 0 1 Detail for 1100011-29 Range for 2 s Complement 2 s Complement: 1100011 Flip : (One s complement) 1011100 Add One: + 1 1011101 Converts to: = - 29 For example, 6-bit 2 s complement notation 100000 100001 111111 000000 000001 011111-32 -31... -1 0 1... 31 Negative, sign bit = 1 Zero or positive, sign bit = 0 kc 6

Ranges (revisited) No. of Unsigned Sign-magnitude 2 s complement bits Min Max Min Max Min Max 1 0 1 2 0 3-1 1-2 1 3 0 7-3 3-4 3 4 0 15-7 7-8 7 5 0 31-15 15-16 15 6 0 63-31 31-32 31 Etc. No. of bits In General (revisited) Unsigned Sign-magnitude 2 s complement Min Max Min Max Min Max n 0 2 n - 1 -(2 n-1-1) 2 n-1-1 -2 n-1 2 n-1-1 To remember 2 s Complement Addition Easy No special rules Just add What is -5 plus +5? Zero, of course, but let s see Sign-magnitude Two s-complement 1 1 1 1 1 1 1 1-5: 10000101-5: 11111011 +5: +00000101 +5: +00000101 10001010 00000000 7

2 s Complement Subtraction Easy No special ilrules Just subtract, well actually just add! What is 10 subtract 3? 7, of course, but Let sdoit(we ll use 6-bit values) 10 3 = 10 + (-3) = 7 A B = A + (-B) add 2 s complement of B +3: 000011 1s C: 111100 +1: 1-3: 111101 001010 +111101 000111 What is 10 subtract -3? 13, of course, but Let s do it (we ll use 6-bit values) (-(-3)) = 3 Overflows and Carries 10 (-3) = 10 + (-(-3)) = 13-3: 111101 1s C: 000010 +1: 1 +3: 000011 001010 +000011 001101 8