Introduction to Number Systems

Slides:



Advertisements
Similar presentations
Intro to CS – Honors I Representing Numbers GEORGIOS PORTOKALIDIS
Advertisements

CS 151 Digital Systems Design Lecture 3 More Number Systems.
Number Systems Standard positional representation of numbers:
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
Number Representation (1) Fall 2005 Lecture 12: Number Representation Integers and Computer Arithmetic.
ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
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.
Number Systems Lecture 02.
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.
NEGATIVE BINARY NUMBER – Digital Circuit 1 Choopan Rattanapoka.
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 :
Computer Systems 1 Fundamentals of Computing Negative Binary.
Number Systems.
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
Simple Data Type Representation and conversion of numbers
Data Representation – Binary Numbers
Computer System & Binary Review. Memory Model What memory is supposed to look like.
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
1 Digital Design: Number Systems Credits : Slides adapted from: J.F. Wakerly, Digital Design, 4/e, Prentice Hall, 2006 C.H. Roth, Fundamentals of Logic.
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved Binary Numbers Appendix.
Number Systems. Today Decimal Hexadecimal Binary –Unsigned Binary –1’s Complement Binary –2’s Complement Binary.
46 Number Systems Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
Computer Number Systems. d n-1 d n-2 d n d 2-m d 1-m d -m Conventional Radix Number r is the radixd i is a digit d i Є {0, 1, ….., r – 1 } -m ≤
ECE 331 – Digital System Design
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
Dr. Ahmed Telba EE208: Logic Design Lecture# 1 Introduction & Number Systems.
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.
Introduction to Computing Dr. Nadeem A Khan. Lecture 10.
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.
Number Systems Binary to Decimal Octal to Decimal Hexadecimal to Decimal Binary to Octal Binary to Hexadecimal Two’s Complement.
Number Systems and Logic Prepared by Dr P Marais (Modified by D Burford)
Computer Math CPS120 Introduction to Computer Science Lecture 4.
AEEE2031 Data Representation and Numbering Systems.
1 Positive numbers are well understood An n-bit number represents numbers from 0 to 2 n -1 n+m bits can be used to represent n-bit integer and m-bit fraction.
Introduction to Microprocessors Chapter 2. Decimal or Base 10 Numbers  Have ten different digits (0-9)  It is a weighted number system. Each position.
WEEK #2 NUMBER SYSTEMS, OPERATION & CODES (PART 1)
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=
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
ECE 171 Digital Circuits Chapter 2 Binary Arithmetic Herbert G. Mayer, PSU Status 1/14/2016 Copied with Permission from prof. Mark PSU ECE.
© Prepared By: Razif Razali 1 CHAPTER TWO TCS1023 NUMBERING SYSTEM.
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.
Computer Organization 1 Data Representation Negative Integers.
ECE 3110: Introduction to Digital Systems Signed Number Conversions and operations.
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
Computer Math CPS120 Introduction to Computer Science Lecture 7.
Dr. ClincyLecture 2 Slide 1 CS Chapter 2 (1 of 5) Dr. Clincy Professor of CS Note: Do not study chapter 2’s appendix (the topics will be covered.
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
Cosc 2150: Computer Organization
Binary & Hex Review.
Addition and Subtraction
Negative Binary Numbers
Introduction to Computing
Number Representation
Integer Real Numbers Character Boolean Memory Address CPU Data Types
Negative Binary Numbers
CSE 102 Introduction to Computer Engineering
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Principles of Computing – UFCFA Lecture-3
Data Representation in Computer Systems
Decimal and binary representation systems
Binary Addition (1 of 2) Two 1-bit values A B A + B 1
Binary & Hex Review.
Presentation transcript:

Introduction to Number Systems

Storyline … Different number systems Why use different ones? Binary / Octal / Hexadecimal Conversions Negative number representation Binary arithmetic Overflow / Underflow

Number Systems Four number system Decimal (10) Binary (2) Octal (8) Hexadecimal (16) ............

Binary numbers? Computers work only on two states Off Basic memory elements hold only two states Zero / One Thus a number system with two elements {0,1} A binary digit – bit !

Decimal numbers 1439 = 1 x 103 + 4 x 102 + 3 x 101 + 9 x 100 Thousands Hundreds Tens Ones Radix = 10

Binary Decimal 1101 = 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20 = 8 + 4 + 0 + 1 (1101)2 = (13)10 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, ….

Decimal Binary 2 13 LSB 1 2 6 2 3 1 2 1 1 MSB (13)10 = (1101)2

Octal Decimal 137 = 1 x 82 + 3 x 81 + 7 x 80 = 1 x 64 + 3 x 8 + 7 x 1 = 64 + 24 + 7 (137)8 = (95)10 Digits used in Octal number system – 0 to 7

Decimal Octal 8 95 LSP 7 8 11 3 8 1 1 MSP (95)10 = (137)8

Hex Decimal BAD = 11 x 162 + 10 x 161 + 13 x 160 = 11 x 256 + 10 x 16 + 13 x 1 = 2816 + 160 + 13 (BAD)16 = (2989)10 A = 10, B = 11, C = 12, D = 13, E = 14, F = 15

Decimal Hex 16 2989 LSP 13 16 186 10 16 11 11 MSP (2989)10 = (BAD)16

Why octal or hex? Ease of use and conversion Three bits make one octal digit 111 010 110 101 7 2 6 5 => 7265 in octal Four bits make one hexadecimal digit 1110 1011 0101 E B 5 => EB5 in hex 4 bits = nibble

Negative numbers Three representations Signed magnitude 1’s complement

Sign magnitude Make MSB represent sign Positive = 0 Negative = 1 E.g. for a 3 bit set “-2” Sign Bit 1 MSB LSB

1’s complement MSB as in sign magnitude Complement all the other bits Given a positive number complement all bits to get negative equivalent E.g. for a 3 bit set “-2” Sign Bit 1

2’s complement 1’s complement plus one E.g. for a 3 bit set “-2” Sign

Decimal number 3 011 2 010 1 001 000 -0 100 --- 111 -1 101 110 -2 -3 Signed magnitude 2’s complement 1’s complement 3 011 2 010 1 001 000 -0 100 --- 111 -1 101 110 -2 -3 -4 No matter which scheme is used we get an even set of numbers but we need one less (odd: as we have a unique zero)

Binary Arithmetic Addition / subtraction Unsigned Signed Using negative numbers

Unsigned: Addition Like normal decimal addition B A 0101 (5) The carry out of the MSB is neglected + 1 10 0101 (5) + 1001 (9) 1110 (14)

Unsigned: Subtraction Like normal decimal subtraction B A A borrow (shown in red) from the MSB implies a negative - 1 11 1001 (9) - 0101 (5) 0100 (4)

Signed arithmetic Use a negative number representation scheme Reduces subtraction to addition

2’s complement Negative numbers in 2’s complement 001 ( 1)10 001 ( 1)10 101 (-3)10 110 (-2)10 The carry out of the MSB is lost

Overflow / Underflow Maximum value N bits can hold : 2n –1 When addition result is bigger than the biggest number of bits can hold. Overflow When addition result is smaller than the smallest number the bits can hold. Underflow Addition of a positive and a negative number cannot give an overflow or underflow.

Overflow example 011 (+3)10 110 (+6)10 ???? 110 (+6)10 ???? 1’s complement computer interprets it as –1 !! (+6)10 = (0110)2 requires four bits !

Underflow examples Two’s complement addition 101 (-3)10 Carry 1 010 (-6)10 ???? The computer sees it as +2. (-6)10 = (1010)2 again requires four bits !