46 Number Systems Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches.

Slides:



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

COE 202: Digital Logic Design Signed Numbers
Binary Representation Introduction to Computer Science and Programming I Chris Schmidt.
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Assembly Language and Computer Architecture Using C++ and Java
1 Lecture 3 Bit Operations Floating Point – 32 bits or 64 bits 1.
Assembly Language and Computer Architecture Using C++ and Java
Number Systems Decimal (Base 10) Binary (Base 2) Hexadecimal (Base 16)
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 =
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
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.
EE 261 – Introduction to Logic Circuits
B0011 Number Systems ENGR xD52 Eric VanWyk Fall 2012.
Number Systems Computer Science 210 Computer Organization.
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
3. Representing Integer Data
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 :
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
Simple Data Type Representation and conversion of numbers
ES 244: Digital Logic Design Chapter 1 Chapter 1: Introduction Uchechukwu Ofoegbu Temple University.
Data Representation – Binary 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.
#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.
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.
Number Systems. Today Decimal Hexadecimal Binary –Unsigned Binary –1’s Complement Binary –2’s Complement Binary.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
Representation of Data Ma King Man. Reference Text Book: Volume 2 Notes: Chapter 19.
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.
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
Operations on Bits Arithmetic Operations Logic Operations
Computer Math CPS120 Introduction to Computer Science Lecture 4.
1 Review on Number Systems Decimal, Binary, and Hexadecimal.
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
Introduction to Microprocessors Chapter 2. Decimal or Base 10 Numbers  Have ten different digits (0-9)  It is a weighted number system. Each position.
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.
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.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
1 Number Systems Decimal, Binary, and Hexadecimal.
IT1004: Data Representation and Organization Negative number representation.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
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.
1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.
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.
Design of Digital Circuits Reading: Binary Numbers
David Kauchak CS 52 – Spring 2017
Addition and Subtraction
Digital Systems and Number Systems
Integer Real Numbers Character Boolean Memory Address CPU Data Types
CSE 102 Introduction to Computer Engineering
University of Gujrat Department of Computer Science
Data Representation Data Types Complements Fixed Point Representation
Presentation transcript:

46 Number Systems Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches Missing: Way to implement numbers in binary Approach: From decimal to binary numbers (and back)

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

48 Base R Numbers Each digit in range 0..(R-1) 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F... A = 10 B = 11 C = 12 D = 13 E = 14 F = 15 Digit position i = Digit * R i 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

49 Number System (Conversion to Decimal) Binary: (101110) 2 = Octal: (325) 8 = Hexadecimal: (E32) 16 =

50 Conversion from Base R to Decimal Binary: (110101) 2 Octal: (524) 8 Hexadecimal: (A6) 16

51 Conversion of Decimal to Binary (Method 1) For positive, unsigned numbers 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)

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

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

54 Decimal to Binary Method 2 Convert (289) 10 to binary

55 Decimal to Binary Method 2 Convert (85) 10 to binary

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

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

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

59 Arithmetic Operations Decimal: Binary: Decimal: Binary:

60 Arithmetic Operations (cont.) * Binary:

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

62 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

63 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

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

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

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

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

68 Subtraction in Two’s Complement A - B = A + (-B) = A + B

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

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

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

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

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