CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.

Slides:



Advertisements
Similar presentations
Binary Systems1 DIGITAL LOGIC DESIGN by Dr. Fenghui Yao Tennessee State University Department of Computer Science Nashville, TN.
Advertisements

Arithmetic Operations and Circuits
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
Chapter Chapter Goals Know the different types of numbers Describe positional notation.
Digital Circuits. Analog and Digital Signals Noise margins in Logic Circuits VMVM.
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
Number System and Codes
Binary Conversion In today’s lesson we will link together the binary and algorithm topics by looking at how to get the computer to: convert binary to decimal.
Arithmetic Operations and Circuits
FIGURES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Convert Decimal to Floating point number [IEEE 754]
Computer Organization & Programming Chapter2 Number Representation and Logic Operations.
1 Week 3: Data Representation: Negative Numbers READING: Chapter 3.
Simple Data Type Representation and conversion of numbers
1 Arithmetic and Logical Operations - Part II. Unsigned Numbers Addition in unsigned numbers is the same regardless of the base. Given a pair of bit sequences.
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
Chapter 7 Arithmetic Operations and Circuits Binary Arithmetic Addition –When the sum exceeds 1, carry a 1 over to the next-more-significant column.
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
Logic and Digital System Design - CS 303
Binary Arithmetic & Data representation
Dale & Lewis Chapter 3 Data Representation. Data and computers Everything inside a computer is stored as patterns of 0s and 1s Numbers, text, audio, video,
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Integer Conversion Between Decimal and Binary Bases Conversion of decimal to binary more complicated Task accomplished by –Repeated division of decimal.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Lecture 4 Last Lecture –Positional Numbering Systems –Converting Between Bases Today’s Topics –Signed Integer Representation Signed magnitude One’s complement.
The Teacher CP4 Binary and all that… CP4 Revision.
Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.
1 Week 2: Binary, Octal and Hexadecimal Numbers READING: Chapter 2.
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
Tutorial: ITI1100 Dewan Tanvir Ahmed SITE, UofO
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
Addition and Substraction
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
WEEK #2 NUMBER SYSTEMS, OPERATION & CODES (PART 1)
Lecture 2 Binary Arithmetic Topics Terminology Fractions Base-r to decimal Unsigned Integers Signed magnitude Two’s complement August 26, 2003 CSCE 211.
Outline Binary Addition 2’s complement Binary Subtraction Half Adder
1 4. Computer Maths and Logic 4.1 Number Systems.
Introduction To Number Systems Binary System M. AL-Towaileb1.
1 Digital Design Debdeep Mukhopadhyay Associate Professor Dept of Computer Science and Engineering NYU Shanghai and IIT Kharagpur.
1 CS 151 : Digital Design Chapter 4: Arithmetic Functions and Circuits 4-3 : Binary Subtraction.
1 Digital Logic Design Engr. Kashif Shahzad. 2 What’s Course About?  Digital logic, focusing on the design of computers  Stay above transistor level.
Computer Organization 1 Data Representation Negative Integers.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
BINARY SYSTEMS ENGR. KASHIF SHAHZAD 1. BINARY NUMBERS 1/2 Internally, information in digital systems is of binary form groups of bits (i.e. binary numbers)
Learning Objectives 3.3.1f - Describe the nature and uses of floating point form 3.3.1h - Convert a real number to floating point form Learn how to normalise.
Unit I From Fundamentals of Logic Design by Roth and Kinney.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Introduction To Number Systems
Integer Real Numbers Character Boolean Memory Address CPU Data Types
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
CSE 102 Introduction to Computer Engineering
Addition and Substraction
Binary Addition & Subtraction
BEE1244 Digital System and Electronics BEE1244 Digital System and Electronic Chapter 2 Number Systems.
Chapter 3 Test Review.
Unit 18: Computational Thinking
CPS120: Introduction to Computer Science
GCSE COMPUTER SCIENCE Topic 3 - Data 3.3 Logical and Arithmetic Shifts.
Introduction To Number Systems
Chapter 1 Introduction.
Presentation transcript:

CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett

Today’s Topics: 1. Number representations in different bases 2. Converting between bases 2

1. Number representations all your base are belong to us 3

Numbers are building blocks

Bases 5

Values in different bases What’s the decimal value of (10001) 2 ? A. (5) 10 B. (17) 10 C. (-1) 10 D. (10001) 10 E. None of the above / more than one of the above.

Values in different bases What’s the base 2 representation of the decimal number (42) 10 ? A. (111111) 2 B. (100001) 2 C. (101010) 2 D. (110011) 2 E. None of the above / more than one of the above.

Values in different bases What’s the biggest integer value whose binary representation has 4 bits? A. 2 4 = (16) 10 B. 2 3 = (8) 10 C. (4) 10 D. (1000) 10 E. None of the above / more than one of the above.

Uniqueness Is it possible to have two different representations for an integer in base 2? That is, is it possible to have A. No. B. Yes, but m has to be the same as n. C. Yes, and m,n can be different but for each kind of coefficient that appears in both, it has to agree. That is, a 0 = b 0, a 1 = b 1, etc. D. Yes, if m=n and all the coefficients agree. E. More than one of the above / none of the above.

Parity and shift

Shifts

Values in different bases What’s the base 2 representation of the decimal number (2014) 10 A. ( ) 2 B. ( ) 2 C. ( ) 2 D. ( ) 2 E. None of the above / more than one of the above.

Values in different bases What’s the base 2 representation of the decimal number (2014) 10 A. ( ) 2 B. ( ) 2 C. ( ) 2 D. ( ) 2 E. None of the above / more than one of the above. Is there a systematic way (aka algorithm) to do it?

Decimal to Binary conversion  Right to left  Questions to ask:  Does it always terminate?  Does it give the correct answer?  What is the time complexity? toBinary(pos int n) Begin binary=“” i=n While i>0 Do If (i is even) Then binary=“0”+binary End If (i is odd) Then binary=“1”+binary End i=i DIV 2 Output binary End.

Other numbers?  Fractional components  Negative numbers aka how to subtract … first, how do we add? A. 111 B. 100 C D E. Other

One bit addition Carry:

Subtraction JS p. 6  Borrowing A – B = (A – 10) + (10 – B)  Carrying A – B = (A+10) – (B+10)  Complementation A – B = A + B c = A + [ (99-B) - 99 ] = A + [ (100-B) – 100 ]

2’s complement Complete the wheel of numbers! How many numbers are we representing with 4 bits?

How to add binary numbers? ? ? ? ? ?

How to add binary numbers? ? ? ? ? ? ? ? ? ? carry ? ? ? ? ?

How to add binary numbers?  Two basic operations:  One-Bit-Addition(bit1, bit2, carry)  Next-carry(bit1, bit2, carry) ? ? ? ? ? ? ? ? ? carry ? ? ? ? ?

Numbers … logic … circuits