69 Decimal (Base 10) Numbers n Positional system - each digit position has a value n 2534 = 2*1,000 + 5*100 + 3*10 + 4*1 n Alternate view: Digit position.

Slides:



Advertisements
Similar presentations
Number Bases Informatics INFO I101 February 9, 2004 John C. Paolillo, Instructor.
Advertisements

ELEC353 S. al Zahir UBC Sign-Magnitude Representation High order bit is sign: 0 = positive (or zero), 1 = negative Low order bits represent the magnitude:
COE 202: Digital Logic Design Signed Numbers
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Arithmetic See: P&H Chapter 3.1-3, C.5-6.
Parallel Adder Recap To add two n-bit numbers together, n full-adders should be cascaded. Each full-adder represents a column in the long addition. The.
Assembly Language and Computer Architecture Using C++ and Java
ECE C03 Lecture 61 Lecture 6 Arithmetic Logic Circuits Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Assembly Language and Computer Architecture Using C++ and Java
Number Systems Decimal (Base 10) Binary (Base 2) Hexadecimal (Base 16)
Chapter # 5: Arithmetic Circuits Contemporary Logic Design Randy H
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
Digital Arithmetic Wen-Hung Liao, Ph.D.. Objectives Perform binary addition, subtraction, multiplication, and division on two binary numbers. Add and.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
Number System and Codes
Chapter 5 Arithmetic Logic Functions. Page 2 This Chapter..  We will be looking at multi-valued arithmetic and logic functions  Bitwise AND, OR, EXOR,
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.
Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University See: P&H Chapter 2.4, 3.2, B.2, B.5, B.6.
Number Systems Lecture 02.
B0011 Number Systems ENGR xD52 Eric VanWyk Fall 2012.
Dr. Bernard Chen Ph.D. University of Central Arkansas
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 :
Simple Data Type Representation and conversion of numbers
Click to edit Master title style Click to edit Master text styles –Second level Third level –Fourth level »Fifth level 1 Today’s Topics How information.
Basic Arithmetic (adding and subtracting)
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
Chapter 2 Number Systems + Codes. Overview Objective: To use positional number systems To convert decimals to binary integers To convert binary integers.
1 CMSC 250 Chapter 1, con't., Combinatorial circuits.
Chapter # 5: Arithmetic Circuits
Topic: Arithmetic Circuits Course: Digital Systems Slide no. 1 Chapter # 5: Arithmetic Circuits.
5-1 Programmable and Steering Logic Chapter # 5: Arithmetic Circuits.
Basic Arithmetic (adding and subtracting)
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.
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.
46 Number Systems Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches.
Lecture 4 Last Lecture –Positional Numbering Systems –Converting Between Bases Today’s Topics –Signed Integer Representation Signed magnitude One’s complement.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
Computer Arithmetic and the Arithmetic Unit Lesson 2 - Ioan Despi.
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.
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.
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 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.
Operations on Bits Arithmetic Operations Logic Operations
1 Review on Number Systems Decimal, Binary, and Hexadecimal.
Kavita Bala CS 3410, Spring 2014 Computer Science Cornell University.
Lecture 2 Binary Arithmetic Topics Terminology Fractions Base-r to decimal Unsigned Integers Signed magnitude Two’s complement August 26, 2003 CSCE 211.
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=
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
1 Number Systems Decimal, Binary, and Hexadecimal.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
Number Representation (Part 2) Computer Architecture (Fall 2006)
Lecture #23: Arithmetic Circuits-1 Arithmetic Circuits (Part I) Randy H. Katz University of California, Berkeley Fall 2005.
ECE 3110: Introduction to Digital Systems Signed Number Conversions and operations.
Electrical Engineering Engineering the Future Digital Circuits Fundamentals Hands-on Full-Adder Simulation (afternoon)
1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.
Arithmetic Circuits I. 2 Iterative Combinational Circuits Like a hierachy, except functional blocks per bit.
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.
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.
Addition and Subtraction
Digital Systems and Number Systems
Digital Arithmetic Wen-Hung Liao, Ph.D..
CSE 102 Introduction to Computer Engineering
University of Gujrat Department of Computer Science
Data Representation Data Types Complements Fixed Point Representation
Arithmetic Circuits (Part I) Randy H
Numbers and Arithmetic and Logical Operation
Presentation transcript:

69 Decimal (Base 10) Numbers n Positional system - each digit position has a value n 2534 = 2*1, * *10 + 4*1 n Alternate view: Digit position I from the right = Digit * 10 I (rightmost is position 0) n 2534 = 2* * * *10 0

70 Base R Numbers n Each digit in range 0..(R-1) n 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F... n A = 10 n B = 11 n C = 12 n D = 13 n E = 14 n F = 15 n Digit position I = Digit * R I n D 3 D 2 D 1 D 0 (base R) = D 3 *R 3 +D 2 *R 2 +D 1 *R 1 +D 0 *R 0

71 Number System (Conversion to Decimal) n Binary: (101110) 2 = n Octal: (7325) 8 = n Hexadecimal: (AFE32) 16 =

72 Conversion from Base R to Decimal n Binary: (110101) 2 n Octal: (6524) 8 n Hexadecimal: (94a6) 16

73 Conversion of Decimal to Binary (Method 1) n For positive, unsigned numbers n Successively subtract the greatest power of two less than the number from the value. Put a 1 in the corresponding digit position 2 0 =1 2 4 = = =4096 (4K) 2 1 =2 2 5 = = =8192 (8K) 2 2 =4 2 6 = =1024 (1K) 2 3 =8 2 7 = =2048 (2K)

74 Decimal to Binary Method 1 n Convert (2578) 10 to binary n Convert (289) 10 to binary

75 Conversion of Decimal to Binary (Method 2) n For positive, unsigned numbers n Repeatedly divide number by 2. Remainder becomes the binary digits (right to left) n Explanation:

76 Decimal to Binary Method 2 n Convert (289) 10 to binary

77 Decimal to Binary Method 2 n Convert (85) 10 to binary

78 Converting Binary to Hexadecimal n 1 hex digit = 4 binary digits n Convert ( ) 2 to hex n Convert (A3FF2A) 16 to binary

79 Converting Binary to Octal n 1 octal digit = 3 binary digits n Convert ( ) 2 to octal n Convert (723642) 8 to binary

80 Converting Decimal to Octal/Hex n Convert to binary, then to other base n Convert (198) 10 to Hexadecimal n Convert ( ) 10 to Octal

81 Arithmetic Operations Decimal: Binary: Decimal: Binary:

82 Arithmetic Operations (cont.) * Binary:

83 Negative Numbers n Need an efficient way to represent negative numbers in binary n Both positive & negative numbers will be strings of bits n Use fixed-width formats (4-bit, 16-bit, etc.) n Must provide efficient mathematical operations n Addition & subtraction with potentially mixed signs n Negation (multiply by -1)

84 Sign/Magnitude Representation = = High order bit is sign: 0 = positive (or zero), 1 = negative Three low order bits is the magnitude: 0 (000) thru 7 (111) Number range for n bits = +/-2 -1 Representations for 0: n-1

85 Sign/Magnitude Addition ( -2) (+4) (+2) (+4) (-2) (-4) (+2) ( -4) Bottom line: Basic mathematics are too complex in Sign/Magnitude Idea: Pick negatives so that addition/subtraction works

86 Idea: Pick negatives so that addition works n Let -1 = 0 - (+1): n Does addition work? n Result: Two’s Complement Numbers ( 0) (+1) (+2) ( -1)

87 Two’s Complement n Only one representation for 0 n One more negative number than positive number n Fixed width format for both pos. & neg. numbers = =

88 Negating in Two’s Complement n Flip bits & Add 1 n Negate (0010) 2 (+2) n Negate (1110) 2 (-2)

89 Addition in Two’s Complement ( -2) (+4) (+2) (+4) (-2) (-4) (+2) ( -4)

90 Subtraction in Two’s Complement n A - B = A + (-B) = A + B + 1 n n n

91 Overflows in Two’s Complement Add two positive numbers to get a negative number or two negative numbers to get a positive number = =

92 Overflow Detection in Two’s Complement Overflow No overflow Overflow when carry in to sign does not equal carry out

93 Converting Decimal to Two’s Complement n Convert absolute value to binary, then negate if necessary n Convert (-9) 10 to 6-bit Two’s Complement n Convert (9) 10 to 6-bit Two’s Complement

94 Converting Two’s Complement to Decimal n If Positive, convert as normal; If Negative, negate then convert. n Convert (11010) 2 to Decimal n Convert (01011) 2 to Decimal

95 Sign Extension n To convert from N-bit to M-bit Two’s Complement (N>M), simply duplicate sign bit: n Convert (1011) 2 to 8-bit Two’s Complement n Convert (0010) 2 to 8-bit Two’s Complement

96 Sign Extension n To convert from N-bit to M-bit Two’s Complement (N>M), simply duplicate sign bit: n Convert (1011) 2 to 8-bit Two’s Complement n Convert (0010) 2 to 8-bit Two’s Complement

97 Half Adder With twos complement numbers, addition is sufficient Half-adder Schematic

98 Full Adder A B CI S CO

99 Full Adder/Half Adder Alternative Implementation: 5 Gates A B + CI (A xor B) = A B + B CI + A CI Standard Approach: 6 Gates + A A A B B B CI S CO

100 Multi-Bit Addition Cascaded Multi-bit Adder usually interested in adding more than two bits this motivates the need for the full adder

101 Adder/Subtractor A - B = A + (-B) = A + B + 1 AB CO S +CI AB CO S +CI AB CO S +CI AB CO S +CI A 3 B 3 A 2 B 2 A 1 B 1 A 0 B 0 S 3 S 2 S 1 S 0 Overflow