Lecture 2: Operations Bryan Burlingame 9Sept2015.

Slides:



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

ECE 331 – Digital System Design
DATA REPRESENTATION CONVERSION.
Number Systems. 2 The total number of allowable symbols in a number system is called the radix or base of the system. Decimal Numbers: radix = 10 (symbols:
CHAPTER 2: Number Systems
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
A bit can have one of two values: 0 or 1. The C language provides four operators that can be used to perform bitwise operations on the individual bits.
Professor Jennifer Rexford COS 217
1 CSE-221 Digital Logic Design (DLD) Lecture-1: Digital Systems & Number Systems.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
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.
Binary Arithmetic Math For Computers.
+ CS 325: CS Hardware and Software Organization and Architecture Integers and Arithmetic.
Simple Data Type Representation and conversion of numbers
Computer Arithmetic Nizamettin AYDIN
Lecture 7 How computers process data (Number Systems) PRESENTED BY MD. MAHBUBUL ALAM, PHD 1.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Supplemental Chapter Number Bases
10-Sep Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Sept Representing Information in Computers:  numbers: counting numbers,
CSC Intro. to Computing Lecture 5: Boolean Logic, Gates, & Circuits.
1 CS103 Guest Lecture Number Systems & Conversion Bitwise Logic Operations.
Copyright © Curt Hill BitWise Operators Packing Logicals with Other Bases as a Bonus.
CHAPTER 3: Number Systems
Chapter1: Number Systems
Number Base Conversions
CHAPTER 3: Number Systems The Architecture of Computer Hardware and Systems Software & Networking: An Information Technology Approach 4th Edition, Irv.
Set A formal collection of objects, which can be anything May be finite or infinite Can be defined by: – Listing the elements – Drawing a picture – Writing.
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
Data Representation Bits, Bytes, Binary, Hexadecimal.
Week 8: Decisions Bryan Burlingame 21 October 2015.
Lecture 1: Course Introduction Overview of Computers and their Applications in MAE B Burlingame 2 September, 2015 Heavily based on work by Dr. Buff Furman,
Number Representation Lecture Topics How are numeric data items actually stored in computer memory? How much space (memory locations) is.
ECE 3110: Introduction to Digital Systems Number Systems.
CHAPTER 3: Number Systems
Lecture 1: Course Introduction Overview of Computers and their Applications in MAE B Burlingame 3 February, 2016 Heavily based on work by Dr. Buff Furman,
CSE 351 Number Representation. Number Bases Any numerical value can be represented as a linear combination of powers of n, where n is an integer greater.
Number Systems and Computer Arithmetic Winter 2014 COMP 1380 Discrete Structures I Computing Science Thompson Rivers University.
Lecture 2: Logic Bryan Burlingame 10 Feb Ref: xkcd:
ECE 2110: Introduction to Digital Systems Number Systems: conversions.
The Hexadecimal System is base 16. It is a shorthand method for representing the 8-bit bytes that are stored in the computer system. This system was chosen.
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.
Lecture 2: Logic Bryan Burlingame 31 Aug 2016.
William Stallings Computer Organization and Architecture 8th Edition
Lecturer: Santokh Singh
Lecture 3: Logic Bryan Burlingame 06 Sept 2017.
Digital Systems and Number Systems
COMPUTING FUNDAMENTALS
William Stallings Computer Organization and Architecture 7th Edition
Fundamentals & Ethics of Information Systems IS 201
Data Structures Mohammed Thajeel To the second year students
Computer Organization and ASSEMBLY LANGUAGE
Number Systems Base 2, 10, 16.
CISC101 Reminders Your group name in onQ is your grader’s name.
Lecture 2 Python Programming & Data Types
CS 240 – Lecture 9 Bit Shift Operations, Assignment Expressions, Modulo Operator, Converting Numeric Types to Strings.
ECEG-3202 Computer Architecture and Organization
Digital Logic Design (CSNB163)
Lecture 2 Python Programming & Data Types
Homework Homework Continue Reading K&R Chapter 2 Questions?
Chapter 8 Computer Arithmetic
COMS 161 Introduction to Computing
GCSE COMPUTER SCIENCE Topic 3 - Data 3.3 Logical and Arithmetic Shifts.
Presentation transcript:

Lecture 2: Operations Bryan Burlingame 9Sept2015

Announcements Homework posted Homework 1 due next week Bring headphones to lab Still do not have Canvas access For Lab, turn in a hard copy

Recall binary Base 2 number system Mimics the actual hardware computers are built upon Two values, 0 and to decimal = 120

Binary to Hexadecimal Hexadecimal (base 16) is a convenient numbering system  0 – 9, A – F (A = 10 10, B = 11 10, etc Observe 2 4 = 16, allows four bits (a nyble) to be grouped = = 0xC 16

Binary to Hexadecimal Convert Binary to Hex b

Binary to Hexadecimal Convert Binary to Hex b (grouping 4 bits) d C 3 9 F h

Hex to Decimal C39Fh 12 * * * * 16 0 = 50,079 CharacterValue F15 E14 D13 C12 B11 A10 0 –

Decimal to binary Many ways, this is how I do it 120  120 < 128, 0 in 7 th position  120 > 64, 1 in 6 th position 120 – 64 = 56  56 > 32, 1 in 5 th position 56 – 32 = 24  24 > 16, 1 in 4 th position 24 – 16 = 8  8 = 8, 1 in 3 rd position 8 – 8 = 0  Once we hit zero, all other values are zero  Why do I do it this way? It is quick when I don’t have a calculator. Your mileage may vary BinaryDecimal

Representations Decimal (default)BinaryHexadecimal 1080’ x6C 108d b6Ch C dec bin6C hex Group by 3s with a comma Group by 4s with a space or an underbar Generally don’t group Spoken short form

Bitwise arithmetic Mimics digital hardware Based on Boolean logic Operates on each bit within a number  (i.e. operates bitwise) Many, many hardware peripherals take advantage of bitwise operations Implemented directly in hardware  Very fast

Binary (Bitwise) And - & & Y X 194 & 225 = (194) & (225) (192) Binary And is commonly used with “bitmasks” A binary & used with a bitmask can ensure that a given bit is turned “off” & is shift + 7

Binary (Bitwise) Or - | | Y X 194 | 225 = (194) | (225) (227) Binary OR, is, also, commonly used with “bitmasks” A binary | used with a bitmask can ensure that a given bit is turned “on” | is shift + \

Binary (Bitwise) Xor - ⊕ ⊕ Y X 194 ^ 225 = (194) ⊕ (225) (35) Xors are commonly used to switch the values of selected bits or to test for inequivalence C uses ^ for Xor ^ is shift + 6

Bitshifts ( > Right Shift) A bit shift shifts bits in a direction Left shift shifts bits to the left and simulates a multiply of 2 Right shift shifts bits to the right and simulates an integer division of 2 Bits outside the range are lost 23 << 3 = 184 (left shift by 3) shifted = >> 2 = 5 (right shift by 2) = 5 (note the last two bits are lost)

True and False Generally, false is zero and true is not- zero Usually, all comparisons which are true generate a 1 (23 > 4) = 1 This comes up a lot!

Modulo Division (%) Integer division which provides the “remainder” from an integer division Assuming integer operations  123 % 6 = 3  123 / 6 = 20 (note, the fractional portion will be dropped) Recall: False is 0, and True is not 0  What does X % 2 give for all odd numbers?

Order of operations – C & Matlab Operators * / %Multiplication, division, modulo (integer) division + -Addition, subtraction >Left bitshift, right bitshift &Bitwise and ^Bitwise xor |Bitwise or

References Nicholas, P. (1994). Digital Design. Minneapolis/St. Paul: West Publishing Company