Number Systems Rayat Shikshan Sanstha’s

Slides:



Advertisements
Similar presentations
HEXADECIMAL NUMBERS Code
Advertisements

Computer Engineering (Logic Circuits) Dr. Tamer Samy Gaafar Lec. # 2
Data Representation COE 205
Number Systems Decimal (Base 10) Binary (Base 2) Hexadecimal (Base 16)
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
Data Representation in Computers. Data Representation in Computers/Session 3 / 2 of 33 Number systems  The additive approach – Number earlier consisted.
Binary Representation - Shortcuts n Negation x + x = 1111…1111 two = -1 (in 2’s complement) Therefore, -x = x + 1 n Sign Extension o Positive numbers :
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION.
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Number systems, Operations, and Codes
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
Operations on Bits Arithmetic Operations Logic Operations
AEEE2031 Data Representation and Numbering Systems.
WEEK #2 NUMBER SYSTEMS, OPERATION & CODES (PART 1)
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
Lecture 2: 8/29/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
CSE370, Lecture 2 Lecture 2: Number Systems  Logistics Webpage is up! HW1 is posted on the web in the calender --- due.
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.
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
Lecture 4: Digital Systems & Binary Numbers (4)
Number Systems & Binary Arithmetic
Data Representation COE 308 Computer Architecture
Cosc 2150: Computer Organization
Design of Digital Circuits Reading: Binary Numbers
Data Representation ICS 233
Lec 3: Data Representation
Data Representation.
Negative numbers: Week 10 Lesson 1
Negative Binary Numbers
Number Systems and Binary Arithmetic
Integer Real Numbers Character Boolean Memory Address CPU Data Types
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
CHAPTER 1 : INTRODUCTION
Digital Arithmetic Wen-Hung Liao, Ph.D..
University of Washington
Logistics Always read the Calendar at
Lecture 2 Topics Binary Arithmetic (Unsigned binary operands)
Negative Binary Numbers
CSE 102 Introduction to Computer Engineering
Number System conversions
Number Systems.
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
University of Gujrat Department of Computer Science
Addition and Substraction
Lecture 2 Topics Binary Arithmetic (Unsigned binary operands)
TAO1221 COMPUTER ARCHITECTURE AND ORGANIZATION LAB 6
Data Representation COE 301 Computer Organization
MMNSS COLLEGE,KOTTIYAM DEPARTMENT OF PHYSICS
Data Representation in Computer Systems
Digital Logic Design (ECEg3141) 2. Number systems, operations & codes 1.
1 The Hardware/Software Interface CSE351 Spring 2011 Module 3: Integers Monday, April 4, 2011.
2’s Complement form 1’s complement form 2’s complement form
CPS120: Introduction to Computer Science
Number Systems Rayat Shikshan Sanstha’s
Number Systems Rayat Shikshan Sanstha’s
Data Representation ICS 233
Binary to Decimal Conversion
ECE 171 Digital Circuits Chapter 2 Binary Arithmetic
ECE 331 – Digital System Design
Lecture 2: Number Systems
Number Systems Rayat Shikshan Sanstha’s
COMS 161 Introduction to Computing
Lecture No.5.
Data Representation COE 308 Computer Architecture
Two’s Complement & Binary Arithmetic
Presentation transcript:

Number Systems Rayat Shikshan Sanstha’s S.M. Joshi College Hadapsar-028 Department of Electronics Science Number Systems Presented by- Dr. Bhalerao S.P

Number Systems Binary numbers Base conversion Arithmetic Sign and magnitude Ones-complement Twos-complement Binary-coded decimal (BCD)

Positional number notation Bases we will use Binary: base 2 Octal: base 8 Decimal: base 10 Hexadecimal: base 16 Positional number system 1012 = 1×22 + 0×21 + 1×20 = 510 63.48 = 6×81 + 3×80 + 4×8–1 = 51.510 A116 = 10×161 + 1×160 = 16110

Base conversion from binary Conversion to octal / hex Binary: 10011110001 Octal: 10 | 011 | 110 | 001 = 23618 Hex: 100 | 1111 | 0001 = 4F116 Conversion to decimal 1012 = 1×22 + 0×21 + 1×20 = 510

Base conversion from decimal Why does this work?

Base conversion from decimal Quotient = N / 2 = 56 / 2 = 111000 / 2 = 11100 remainder 0 Each successive division "liberates" a least significant bit

Arithmetic 6912 10101 Decimal Binary 11 1234 5274 + 5678 – 1638 3636 1011 + 1010 10101 1011 – 0110 0101

Negative numbers How do we write negative binary numbers? Prefix numbers with minus symbol? 3 approaches: Sign and magnitude Ones-complement Twos-complement All 3 approaches represent positive numbers in the same way

Sign and magnitude Most significant bit (MSB) is the sign bit 0 ≡ positive 1 ≡ negative Remaining bits are the number's magnitude 0000 0001 0011 1111 1110 1100 1011 1010 1000 0111 0110 0100 0010 0101 1001 1101 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 – 0 – 1 – 2 – 3 – 4 – 5 – 6 – 7

Sign and magnitude Problem 1: Two representations of for zero +0 = 0000 and also –0 = 1000 Problem 2: Arithmetic is cumbersome 4 – 3 != 4 + (-3)

Ones-complement Negative number: Bitwise complement of positive number 0111 ≡ 710 1000 ≡ –710 0000 0001 0011 1111 1110 1100 1011 1010 1000 0111 0110 0100 0010 0101 1001 1101 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 – 7 – 6 – 5 – 4 – 3 – 2 – 1 – 0

Ones-complement Solves the arithmetic problem end-around carry

Why ones-complement works The ones-complement of an 4-bit positive number y is 11112 – y 0111 ≡ 710 11112 – 01112 = 10002 ≡ –710 What is 11112? 1 less than 100002 = 24 – 1 –y is represented by (24 – 1) – y

Why ones-complement works Adding representations of x and –y where x, y are positive numbers, we get x + ((24 – 1) – y) = (24 – 1) + (x – y) If x < y, then x – y < 0. There will be no carry from (24 – 1) + (x – y). Just add representations to get correct negative number. If x > y, then x – y > 0. There will be a carry. Performing end-around carry subtracts 24 and adds 1, subtracting (24 – 1) from (24 – 1) + (x – y) If x = y, then answer should be 0, get (24 – 1) = 11112

So what's wrong? Still have two representations for zero! +0 = 0000 and also –0 = 1111

Twos-complement Negative number: Bitwise complement plus one Benefits: 0111 ≡ 710 1001 ≡ –710 Benefits: Simplifies arithmetic Only one zero! 0000 0001 0011 1111 1110 1100 1011 1010 1000 0111 0110 0100 0010 0101 1001 1101 + 1 + 2 + 3 + 4 + 5 + 6 + 7 – 8 – 7 – 6 – 5 – 4 – 3 – 2 – 1

Twos-complement

Why twos-complement works Recall: The ones-complement of a b-bit positive number y is (2b – 1) – y Twos-complement adds one to the bitwise complement, thus, –y is 2b – y –y and 2b – y are equal mod 2b (have the same remainder when divided by 2b) Ignoring carries is equivalent to doing arithmetic mod 2b

Why twos-complement works Adding representations of x and –y where x, y are positive numbers, we get x + (2b – y) = 2b + (x – y) If there is a carry, that means that x  y and dropping the carry yields x – y If there is no carry, then x < y, then we can think of it as 2b – (y – x), which is the twos-complement representation of the negative number resulting from x – y.

Overflow Answers only correct mod 2b Summing two positive numbers can give a negative result Summing two negative numbers can give a positive result 0000 0001 0011 1111 1110 1100 1011 1010 1000 0111 0110 0100 0010 0101 1001 1101 + 1 + 2 + 3 + 4 + 5 + 6 + 7 – 8 – 7 – 6 – 5 – 4 – 3 – 2 – 1 6 + 4 ⇒ –6 –7 – 3 ⇒ +6

Miscellaneous Sign-extension Write +6 and –6 as twos-complement 0110 and 1010 Sign-extend to 8-bit bytes 00000110 and 11111010 Can't infer a representation from a number 11001 is 25 (unsigned) 11001 is -9 (sign and magnitude) 11001 is -6 (ones complement) 11001 is -7 (twos complement)

BCD (Binary-Coded Decimal) Symbols 1 2 3 4 5 6 7 8 9 BCD Code 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001