Wednesday, September 6, 2017

Size: px
Start display at page:

Download "Wednesday, September 6, 2017"

Transcription

1 Wednesday, September 6, 2017 Topics for today Arithmetic operations and status bits Logical operators Introduction to bigger bases Encoding characters Coding in general Status bits We saw last time that the CPU gives us simple feedback on an operation it performs. This is true both for arithmetic operations and logical operations (see later). Input 1 Input 2 Operation Select N Z V C Result N - the result was negative Z - the result was zero C - there was a carry out from the most significant stage V - there was overflow (=error) Comp 162 Notes Page 1 of 13 September 6, 2017

2 Here are example 5-bit additions showing the operands, result and the values of each of the 4 status bits Operand Operand Result (1)00000 (1)11110 (1) N Z V C We will see later (chapter 6) how we can use these status bits to make flow-of-control decisions inside a program. Logical operations (section 3.3) In general a CPU will have an "Arithmetic and Logic Unit" (ALU). Arithmetic operations: addition, subtraction (maybe multiplication and division) Logical operations: AND, OR, XOR and shift. Logical operations are fast compared with arithmetic operations because they are typically bitwise operations in which the bit positions of a result can be computed independently in parallel. In contrast, an ADD operation may have to wait for a carry to propagate the length of the operands (consider ). Truth tables (using 0 for false and 1 for true) A B A and B A or B A xor B The "Exclusive-OR" (XOR) is so named because it excludes from being true the case where both inputs are true. Examples AND OR XOR Comp 162 Notes Page 2 of 13 September 6, 2017

3 Q. How many other functions of two variables are there (not all useful)? A. 13. If there are N variables, there are 2 N rows in the truth table. A single column can thus be filled in 2^2 N ways each representing a function. With N=2 above there are 2 4 = 16 functions of which we show 3. Here are a couple of applications of XOR (1) Exchanging values We can exchange the values in two variables without using a third. For example, if the variables are A and B, the sequence of operations is A = A xor B B = A xor B A = A xor B Trace A B Initial A = A xor B B = A xor B A = A xor B (2) Encryption To encrypt a message, we XOR it with a key of the same length. To decrypt it we XOR it with the same key see following example Example Message Key Encrypted message Encrypted message Key Message Comp 162 Notes Page 3 of 13 September 6, 2017

4 Without the key, the encrypted message is unbreakable 1. Using a particular key only once yields a strong system particularly if the bits in the key are truly random. Some combinations of logical and math operations Here are some interesting results of combining arithmetic with logical operations (1) x and (x-1) : result is x with rightmost 1 removed Example (84) and (83) rightmost 1 of 84 goes away (2) x and (-x) result is rightmost 1 of x ( = highest power of 2 that divides x) 2 Example (84) and (-84) result: the rightmost 1 of 84 4 is the highest power of 2 that divides 84 (3) x or (-x) smear rightmost 1 of x to the left Example (84) or (-84) the rightmost 1 of 84 copied left (4) x exor (-x) remove and smear rightmost 1 to left Example (84) exor (-84) removed and copied left 1 See story about carrier pigeon at It is thought that a one-time pad might have been used. Without the correct page, the message is undecipherable. 2 In Pep/9 assembly code this operation requires only three instructions: LDWA X,d ; Register A contains X NEGA ; Register A contains -X ANDA X,d ; Register A contains (X logicaland X) Comp 162 Notes Page 4 of 13 September 6, 2017

5 (5) x or (x-1) smear rightmost 1 to right Example (84) or (83) the rightmost 1 smeared right (6) x exor (x-1) extract then smear rightmost 1 to right Example (84) exor (83) the rightmost 1 smeared right Shift operations Shift operations are also logical operations (though arithmetic shift can be also be regarded as an arithmetic operation). A typical shift operation takes a single operand and moves all the bits one place left or right. Suppose we start with a 6-bit object containing a b c d e f The following table shows the results of six different types of shift operations. Type of Shift Left Right Arithmetic b c d e f 0 a a b c d e Logical b c d e f 0 0 a b c d e Rotate/Circular b c d e f a f a b c d e Arithmetic: Shift left is equivalent to multiplication by 2 (unless it overflows). Shift right is equivalent to truncated division by 2. For example, rightshift(7) = 3. Note the sign extension the sign bit does not change so if we shift a negative number rightwards, it is still negative. Comp 162 Notes Page 5 of 13 September 6, 2017

6 Pep/9 has arithmetic shift instructions which we can use to implement the following pseudocode algorithm that computes X=A*B for A >=0. X=0 while (A 0) { if (A%2=1) X=X+B A /= 2 B *= 2; } A%2=1 logicaland(a,1) and test result A /= 2 rightshift(a) B *= 2 leftshift(b) Logical: Both left and right shifts brings in zero bits at the appropriate end Rotate/Circular: May or may not involve the carry bit depending on implementation. If not, a bit that falls off one end is introduced at the other end. In the Pep/9 implementation of Rotate, the Carry bit is in the loop: C bit... Packing and unpacking data Logical operations used in combination are useful in packing and unpacking data like putting several items into a lunchbox. For example, we can pack several independent data items into a 16- bit word. The following shows how five items of student data can be stored in this way Field Size (bits) Depicted Values Student type 1 a 0= undergraduate, 1=graduate Level 2 bb If undergraduate: freshman, senior If graduate: 2ndBS/MS/MBA/PhD Major 5 ccccc Encode up to 32 majors GPA 3 ddd 8 GPA bands: , Enrolled units 5 eeeee Up to 31 units Comp 162 Notes Page 6 of 13 September 6, 2017

7 Thus represents a junior undergraduate Major = 3 (History perhaps) GPA in range 3.00 to 3.49 enrolled in 15 units. Packing the data Suppose the five values to be stored are in appropriately named variables. We can build up the packed data representation in a variable (R) with a sequence of shift and add operations. Initialize R R = R = leftshift(1) + undergrad (0) R = R = leftshift(2) + junior (10) R = R = leftshift(5)+ major (00011) R = R = leftshift(3)+gpa (110) R = R = leftshift(5)+units (01111) R = Unpacking the data Suppose we have student data packed into a variable S and we wish to extract the GPA field (ddd). abbcccccdddeeeee we can accomplish that by first using an AND operation to clear all the other bits to zero then using a shift operation to move the ddd field down to the right end If the data is in S. Then S = S AND ' ' S = rightshift(5) S is now ddd00000 S is now ddd Bigger bases (section 3.4) Binary numbers are tedious to write and it is easy to make mistakes. Look at the binary constant in the AND operation above; it is easy to get the number of zeros wrong. Using a bigger base will result in shorter numbers but we have seen that conversions between binary and decimal can be time-consuming. Comp 162 Notes Page 7 of 13 September 6, 2017

8 Bases 8 and 16 are often more convenient than decimal because each is about as compact as decimal and conversion to and from binary involves simply mapping a group of bits onto a single digit. In octal the groups are 3 bits and in hexadecimal the groups have 4 bits. Octal (Base 8, digits 0..7) The constant that we wrote as would be = in octal. We group digits in threes outwards from where the binary point would be. So a fractional binary number Would be (0) = in octal. (add an extra zero to make a group of three) The problem with octal is that the size of data objects in a computer is typically a multiple of 4 not 3. For example, we have 8-bit bytes, 32-bit and 64-bit registers and so on. This leads us to prefer hexadecimal Hexadecimal (Base 16, use 0..9 and A..F) We group bits in fours so there are 16 possible combinations. In addition to the decimal digits we use the first 6 letters of the alphabet (it usually doesn t matter whether we use upper or lower case). The main problem with hexadecimal is remembering which letter represents which bit pattern is A 1011 is B 1100 is C 1101 is D 1110 is E 1111 is F To convert binary to hexadecimal, group digits in fours outwards from where the binary point would be. For example = = 00E0 in hex = = A35E As in our octal example, if we have a fraction we may have to pad out the fraction bits Comp 162 Notes Page 8 of 13 September 6, 2017

9 = (0) = DC.CA If the number of bits to the left of the point is not a multiple of 4, we pad them also but need to know if the number is signed or unsigned. For instance if signed (pad out with sign bit) = ED if unsigned (pad out with zero) = 2D.1 When a programming language permits both decimal and hexadecimal constants it usually tags hex constants in some way. For example, the number 1234 (base 16) might appear in a program as 0x1234 or #1234h Pep/9 has a instruction (HEXO) that outputs an integer in hexadecimal but no corresponding input instruction. We know that integers can be represented in many ways. If we see a byte and we know it represents an integer, we would need to know the encoding method used in order to know what number it represents. The following table shows the value of in various mappings. Number system Value unsigned s complement s complement -67 Sign and magnitude -61 Excess magnitude 67 If we don t even know it is an integer, there are other things it might be. Characters The ASCII coding scheme is shown in Figure It shows how 128 characters (some printable characters, some control characters) are mapped onto 7-bit codewords. Note that the letters are assigned to consecutive codes and the digits are assigned to consecutive codes. This makes sorting of alphanumeric data much simpler. Comp 162 Notes Page 9 of 13 September 6, 2017

10 Also note that the codewords for an upper case letter and the corresponding lower case letter differ in only one bit position, e.g. H = h = ^ Case bit These features of the ASCII code makes it possible to write: * a simple check to see if a letter is upper case or lower case * instructions to change the case of a letter * case-insensitive matching ( so artichoke = ArtiCHoKe ). Unicode ASCII and similar 7-bit and 8-bit codes are being superceded by Unicode ( which is a 16-bit code. The space requirements are thus twice as big but we can encode a much greater variety of alphabets (Chinese, Korean, Cyrillic, Japanese, Arabic etc). Here are some examples پ Ж א ĝ There are many technical issues to be worked out when dealing with different languages. An example is determining how strings are to be sorted what is the collating order of characters? In Swedish z < ö whereas in German ö < z Coding in general If you need to encode an item (e.g., day of week, student s major, color of a car) how many bits do you need? It the item has M possible different values you would need ceiling(log2 (M)) bits. So Day of week = 3 bits Day of month = 5 bits Month in year = 4 bits and so on. Comp 162 Notes Page 10 of 13 September 6, 2017

11 Generally we don't need to know the exact value of log2(m), just be familiar with powers of 2. For example if M is 200, we know that 2 7 is 128 and 2 8 is 256 so we would need 8 bits to represent values. Example. How could we encode the time of day (to the nearest second)? Method 1: Method 2: We could represent it by the number of seconds after midnight. This would be a number in the range *60*60 = This is a number between 2 16 (65536) and 2 17 (131072) so we would need 17 bits. We could represent the time by a 3-field object (hours-minutes-seconds). Hours (0..23) would need 5 bits, minutes (0..60) would need 6 bits and seconds (0..60) would need 6 bits. Total 17 bits same as Method 1. (This might suggest that the information content of the time to the nearest second is 17 bits.) The different representations, even though same size, have different advantages/ disadvantages. For example, using Method 1 to encode times, it is easy to find the number of seconds between two times. Using Method 2 it is easier to output a time in the HH:MM:SS format. Similarly to represent a date within a year requires 9 bits either as days-since-jan-1st or as Month (4 bits):day (5 bits). Alternatives are not always the same size. Consider the following variation on a problem in the text book Q: You own a (small) paint store and wish to attach a binary code to each paint can. How many bits does each label need if There are three sizes: 5 gallon, 1 gallon, half-gallon There are five colors: black, white, red, green, blue There are two types of paint: indoor, outdoor? A: If we code the fields separately we need 6 bits (2 for size, 3 for color, 1 for type). However, there are only 30 combinations so we could devise a 5-bit code Reading: Chapter 3 except for Sections 3.5 and 3.6. Comp 162 Notes Page 11 of 13 September 6, 2017

12 Review Questions 1. What do the 2 s complement binary representations of N and N have in common? For example, look at 26 and -26 and at 16 and What is the result of (a) exor-ing a number with itself, (b) exor-ing a number with zero (c) exor-ing a number with -1 (all 1s)? 3. Express the answers to the following 16-bit operations as hexadecimal numbers (a) 0x1234 AND 0x1277 (b) 0x7742 OR 0x1003 (c) 0x1750 EXOR 0xABCD 4. A student, given an 8-bit number to convert to octal, grouped the bits in threes from the lefthand end instead of the right-hand end and came up with 513 (a) What was the binary number? (b) What is the correct octal? 5. A student, given an 11-bit number to convert to hexadecimal, grouped the bits in fours from the left-hand end instead of the right-hand end and came up with AF1 (a) What was the binary number? (b) What is the correct octal? 6. Suppose byte X contains the ASCII code of a letter. What logical operation will isolate the case bit. 7. The Unix designers chose 32-bit signed binary integers to represent time. Suppose instead they had used the same number of bits to code the following fields separately Month, day, hour, minute, seconds, am/pm How many bits could be used for the year? When will this encoding fail? Comp 162 Notes Page 12 of 13 September 6, 2017

13 Review Answers 1. From right to left they are identical up to and including the first 1 digit 2. (a) zero (b) the original number (c) the ones complement of the number 3. (a) 0x1234 (b) 0x7743 (c) 0xBC9D 4. (a) (b) (a) (b) AND with (2016). Result will be if upper case and if lower case. 7. The number of bits to encode the named fields separately is 26 as follows: Month Day Hour Minutes Seconds AM/PM This leaves 6 bits for the year, so the largest year possible is = Comp 162 Notes Page 13 of 13 September 6, 2017

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR UNIT I Digital Systems: Binary Numbers, Octal, Hexa Decimal and other base numbers, Number base conversions, complements, signed binary numbers, Floating point number representation, binary codes, error

More information

Introduction to Numbering Systems

Introduction to Numbering Systems NUMBER SYSTEM Introduction to Numbering Systems We are all familiar with the decimal number system (Base 10). Some other number systems that we will work with are Binary Base 2 Octal Base 8 Hexadecimal

More information

Inf2C - Computer Systems Lecture 2 Data Representation

Inf2C - Computer Systems Lecture 2 Data Representation Inf2C - Computer Systems Lecture 2 Data Representation Boris Grot School of Informatics University of Edinburgh Last lecture Moore s law Types of computer systems Computer components Computer system stack

More information

Wednesday, September 13, Chapter 4

Wednesday, September 13, Chapter 4 Wednesday, September 13, 2017 Topics for today Introduction to Computer Systems Static overview Operation Cycle Introduction to Pep/9 Features of the system Operational cycle Program trace Categories of

More information

Number System. Introduction. Decimal Numbers

Number System. Introduction. Decimal Numbers Number System Introduction Number systems provide the basis for all operations in information processing systems. In a number system the information is divided into a group of symbols; for example, 26

More information

Topic Notes: Bits and Bytes and Numbers

Topic Notes: Bits and Bytes and Numbers Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2010 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review, but we will go over it for

More information

Computer Arithmetic. In this article we look at the way in which numbers are represented in binary form and manipulated in a computer.

Computer Arithmetic. In this article we look at the way in which numbers are represented in binary form and manipulated in a computer. Computer Arithmetic In this article we look at the way in which numbers are represented in binary form and manipulated in a computer. Numbers have a long history. In Europe up to about 400 numbers were

More information

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation Data Representation II CMSC 313 Sections 01, 02 The conversions we have so far presented have involved only unsigned numbers. To represent signed integers, computer systems allocate the high-order bit

More information

The type of all data used in a C++ program must be specified

The type of all data used in a C++ program must be specified The type of all data used in a C++ program must be specified A data type is a description of the data being represented That is, a set of possible values and a set of operations on those values There are

More information

Binary Values. CSE 410 Lecture 02

Binary Values. CSE 410 Lecture 02 Binary Values CSE 410 Lecture 02 Lecture Outline Binary Decimal, Binary, and Hexadecimal Integers Why Place Value Representation Boolean Algebra 2 First: Why Binary? Electronic implementation Easy to store

More information

CS & IT Conversions. Magnitude 10,000 1,

CS & IT Conversions. Magnitude 10,000 1, CS & IT Conversions There are several number systems that you will use when working with computers. These include decimal, binary, octal, and hexadecimal. Knowing how to convert between these number systems

More information

COMP Overview of Tutorial #2

COMP Overview of Tutorial #2 COMP 1402 Winter 2008 Tutorial #2 Overview of Tutorial #2 Number representation basics Binary conversions Octal conversions Hexadecimal conversions Signed numbers (signed magnitude, one s and two s complement,

More information

Number Systems CHAPTER Positional Number Systems

Number Systems CHAPTER Positional Number Systems CHAPTER 2 Number Systems Inside computers, information is encoded as patterns of bits because it is easy to construct electronic circuits that exhibit the two alternative states, 0 and 1. The meaning of

More information

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation Course Schedule CS 221 Computer Architecture Week 3: Information Representation (2) Fall 2001 W1 Sep 11- Sep 14 Introduction W2 Sep 18- Sep 21 Information Representation (1) (Chapter 3) W3 Sep 25- Sep

More information

Advanced Computer Architecture-CS501

Advanced Computer Architecture-CS501 Advanced Computer Architecture Lecture No. 34 Reading Material Vincent P. Heuring & Harry F. Jordan Chapter 6 Computer Systems Design and Architecture 6.1, 6.2 Summary Introduction to ALSU Radix Conversion

More information

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1 IT 1204 Section 2.0 Data Representation and Arithmetic 2009, University of Colombo School of Computing 1 What is Analog and Digital The interpretation of an analog signal would correspond to a signal whose

More information

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM 1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM 1.1 Introduction Given that digital logic and memory devices are based on two electrical states (on and off), it is natural to use a number

More information

Chapter 10 Error Detection and Correction 10.1

Chapter 10 Error Detection and Correction 10.1 Chapter 10 Error Detection and Correction 10.1 10-1 INTRODUCTION some issues related, directly or indirectly, to error detection and correction. Topics discussed in this section: Types of Errors Redundancy

More information

Lecture 2: Number Systems

Lecture 2: Number Systems Lecture 2: Number Systems Syed M. Mahmud, Ph.D ECE Department Wayne State University Original Source: Prof. Russell Tessier of University of Massachusetts Aby George of Wayne State University Contents

More information

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers Outline of Introduction Administrivia What is computer architecture? What do computers do? Representing high level things in binary Data objects: integers, decimals, characters, etc. Memory locations (We

More information

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Chapter Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize two

More information

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Chapter 2 Bits, Data Types, and Operations Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University How do we represent data in a computer?!

More information

Topic Notes: Bits and Bytes and Numbers

Topic Notes: Bits and Bytes and Numbers Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2011 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review for most of you, but we start

More information

Bits, Words, and Integers

Bits, Words, and Integers Computer Science 52 Bits, Words, and Integers Spring Semester, 2017 In this document, we look at how bits are organized into meaningful data. In particular, we will see the details of how integers are

More information

Chapter 4. Operations on Data

Chapter 4. Operations on Data Chapter 4 Operations on Data 1 OBJECTIVES After reading this chapter, the reader should be able to: List the three categories of operations performed on data. Perform unary and binary logic operations

More information

Review of Data Representation & Binary Operations Dhananjai M. Rao CSA Department Miami University

Review of Data Representation & Binary Operations Dhananjai M. Rao CSA Department Miami University Review of Data Representation & Binary Operations Dhananjai M. Rao () CSA Department Miami University 1. Introduction In digital computers all data including numbers, characters, and strings are ultimately

More information

Wednesday, January 28, 2018

Wednesday, January 28, 2018 Wednesday, January 28, 2018 Topics for today History of Computing (brief) Encoding data in binary Unsigned integers Signed integers Arithmetic operations and status bits Number conversion: binary to/from

More information

When using computers, it should have a minimum number of easily identifiable states.

When using computers, it should have a minimum number of easily identifiable states. EET 3 Chapter Number Systems (B) /5/4 PAGE Number Systems (B) Number System Characteristics (Tinder) What s important in choosing a number system? Basically, there are four important characteristics desirable

More information

COMP2121: Microprocessors and Interfacing. Number Systems

COMP2121: Microprocessors and Interfacing. Number Systems COMP2121: Microprocessors and Interfacing Number Systems http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 1 Overview Positional notation Decimal, hexadecimal, octal and binary Converting

More information

CS 101: Computer Programming and Utilization

CS 101: Computer Programming and Utilization CS 101: Computer Programming and Utilization Jul-Nov 2017 Umesh Bellur (cs101@cse.iitb.ac.in) Lecture 3: Number Representa.ons Representing Numbers Digital Circuits can store and manipulate 0 s and 1 s.

More information

N.B. These pastpapers may rely on the knowledge gained from the previous chapters.

N.B. These pastpapers may rely on the knowledge gained from the previous chapters. N.B. These pastpapers may rely on the knowledge gained from the previous chapters. 1 SEC 95-PAPER 1-Q5 (a) A computer uses 8-bit two s complement numbers. In the space below fill in the largest positive

More information

Data Representation 1

Data Representation 1 1 Data Representation Outline Binary Numbers Adding Binary Numbers Negative Integers Other Operations with Binary Numbers Floating Point Numbers Character Representation Image Representation Sound Representation

More information

Wednesday, February 4, Chapter 4

Wednesday, February 4, Chapter 4 Wednesday, February 4, 2015 Topics for today Introduction to Computer Systems Static overview Operation Cycle Introduction to Pep/8 Features of the system Operational cycle Program trace Categories of

More information

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: Bits and Bytes and Numbers Number Systems Much of this is review, given the 221 prerequisite Question: how high can

More information

Chapter 2. Data Representation in Computer Systems

Chapter 2. Data Representation in Computer Systems Chapter 2 Data Representation in Computer Systems Chapter 2 Objectives Understand the fundamentals of numerical data representation and manipulation in digital computers. Master the skill of converting

More information

Learning the Binary System

Learning the Binary System Learning the Binary System www.brainlubeonline.com/counting_on_binary/ Formated to L A TEX: /25/22 Abstract This is a document on the base-2 abstract numerical system, or Binary system. This is a VERY

More information

Chapter 2: Number Systems

Chapter 2: Number Systems Chapter 2: Number Systems Logic circuits are used to generate and transmit 1s and 0s to compute and convey information. This two-valued number system is called binary. As presented earlier, there are many

More information

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds. ECE-78: Digital Logic Design Fall 6 UNSIGNED INTEGER NUMBERS Notes - Unit 4 DECIMAL NUMBER SYSTEM A decimal digit can take values from to 9: Digit-by-digit representation of a positive integer number (powers

More information

Chapter 4: Computer Codes. In this chapter you will learn about:

Chapter 4: Computer Codes. In this chapter you will learn about: Ref. Page Slide 1/30 Learning Objectives In this chapter you will learn about: Computer data Computer codes: representation of data in binary Most commonly used computer codes Collating sequence Ref. Page

More information

COMP2611: Computer Organization. Data Representation

COMP2611: Computer Organization. Data Representation COMP2611: Computer Organization Comp2611 Fall 2015 2 1. Binary numbers and 2 s Complement Numbers 3 Bits: are the basis for binary number representation in digital computers What you will learn here: How

More information

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds. UNSIGNED INTEGER NUMBERS Notes - Unit 4 DECIMAL NUMBER SYSTEM A decimal digit can take values from to 9: Digit-by-digit representation of a positive integer number (powers of ): DIGIT 3 4 5 6 7 8 9 Number:

More information

Module 2: Computer Arithmetic

Module 2: Computer Arithmetic Module 2: Computer Arithmetic 1 B O O K : C O M P U T E R O R G A N I Z A T I O N A N D D E S I G N, 3 E D, D A V I D L. P A T T E R S O N A N D J O H N L. H A N N E S S Y, M O R G A N K A U F M A N N

More information

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

10.1. Unit 10. Signed Representation Systems Binary Arithmetic 0. Unit 0 Signed Representation Systems Binary Arithmetic 0.2 BINARY REPRESENTATION SYSTEMS REVIEW 0.3 Interpreting Binary Strings Given a string of s and 0 s, you need to know the representation system

More information

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS). 2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS). 2.. Natural Binary Code (NBC). The positional code with base 2 (B=2), introduced in Exercise, is used to encode

More information

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning 4 Operations On Data 4.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List the three categories of operations performed on data.

More information

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Chapter 2 Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize

More information

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning 4 Operations On Data 4.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List the three categories of operations performed on data.

More information

Characters, Strings, and Floats

Characters, Strings, and Floats Characters, Strings, and Floats CS 350: Computer Organization & Assembler Language Programming 9/6: pp.8,9; 9/28: Activity Q.6 A. Why? We need to represent textual characters in addition to numbers. Floating-point

More information

Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997

Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997 Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997 APPENDIX A.1 Number systems and codes Since ten-fingered humans are addicted to the decimal system, and since computers

More information

Computer Organization

Computer Organization Computer Organization Register Transfer Logic Number System Department of Computer Science Missouri University of Science & Technology hurson@mst.edu 1 Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5,

More information

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC 1 2 Semester Transition Point EE 109 Unit 11 Binary Arithmetic At this point we are going to start to transition in our class to look more at the hardware organization and the low-level software that is

More information

The Design of C: A Rational Reconstruction

The Design of C: A Rational Reconstruction The Design of C: A Rational Reconstruction 1 Goals of this Lecture Help you learn about: The decisions that were available to the designers of C The decisions that were made by the designers of C and thereby

More information

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS Aleksandar Milenković The LaCASA Laboratory, ECE Department, The University of Alabama in Huntsville Email: milenka@uah.edu Web:

More information

Objectives. Connecting with Computer Science 2

Objectives. Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn how numbering systems are used to count Understand the significance of positional value

More information

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS Aleksandar Milenković The LaCASA Laboratory, ECE Department, The University of Alabama in Huntsville Email: milenka@uah.edu Web:

More information

Memory Addressing, Binary, and Hexadecimal Review

Memory Addressing, Binary, and Hexadecimal Review C++ By A EXAMPLE Memory Addressing, Binary, and Hexadecimal Review You do not have to understand the concepts in this appendix to become well-versed in C++. You can master C++, however, only if you spend

More information

Signed Binary Numbers

Signed Binary Numbers Signed Binary Numbers Unsigned Binary Numbers We write numbers with as many digits as we need: 0, 99, 65536, 15000, 1979, However, memory locations and CPU registers always hold a constant, fixed number

More information

Chapter 10 Error Detection and Correction. Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Chapter 10 Error Detection and Correction. Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 10 Error Detection and Correction 0. Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Note The Hamming distance between two words is the number of differences

More information

The Design of C: A Rational Reconstruction"

The Design of C: A Rational Reconstruction The Design of C: A Rational Reconstruction 1 Goals of this Lecture Help you learn about: The decisions that were available to the designers of C The decisions that were made by the designers of C and thereby

More information

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010 Contents Number systems and conversion Binary arithmetic Representation of negative numbers Addition of two s complement numbers Addition of one s complement numbers Binary s Readings Unit.~. UNIT NUMBER

More information

Internal Data Representation

Internal Data Representation Appendices This part consists of seven appendices, which provide a wealth of reference material. Appendix A primarily discusses the number systems and their internal representation. Appendix B gives information

More information

BINARY SYSTEM. Binary system is used in digital systems because it is:

BINARY SYSTEM. Binary system is used in digital systems because it is: CHAPTER 2 CHAPTER CONTENTS 2.1 Binary System 2.2 Binary Arithmetic Operation 2.3 Signed & Unsigned Numbers 2.4 Arithmetic Operations of Signed Numbers 2.5 Hexadecimal Number System 2.6 Octal Number System

More information

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal Positional notation Ch.. /continued Conversions between Decimal and Binary Binary to Decimal - use the definition of a number in a positional number system with base - evaluate the definition formula using

More information

Binary Codes. Dr. Mudathir A. Fagiri

Binary Codes. Dr. Mudathir A. Fagiri Binary Codes Dr. Mudathir A. Fagiri Binary System The following are some of the technical terms used in binary system: Bit: It is the smallest unit of information used in a computer system. It can either

More information

Goals for this Week. CSC 2400: Computer Systems. Bits, Bytes and Data Types. Binary number system. Finite representations of binary integers

Goals for this Week. CSC 2400: Computer Systems. Bits, Bytes and Data Types. Binary number system. Finite representations of binary integers CSC 2400: Computer Systems Bits, Bytes and Data Types 1 Goals for this Week Binary number system Why binary? Converting between decimal and binary and octal and hexadecimal number systems Finite representations

More information

Integers. N = sum (b i * 2 i ) where b i = 0 or 1. This is called unsigned binary representation. i = 31. i = 0

Integers. N = sum (b i * 2 i ) where b i = 0 or 1. This is called unsigned binary representation. i = 31. i = 0 Integers So far, we've seen how to convert numbers between bases. How do we represent particular kinds of data in a certain (32-bit) architecture? We will consider integers floating point characters What

More information

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other Kinds Of Data CHAPTER 3 DATA REPRESENTATION Numbers Integers Unsigned Signed Reals Fixed-Point Floating-Point Binary-Coded Decimal Text ASCII Characters Strings Other Graphics Images Video Audio Numbers

More information

Monday, January 27, 2014

Monday, January 27, 2014 Monday, January 27, 2014 Topics for today History of Computing (brief) Encoding data in binary Unsigned integers Signed integers Arithmetic operations and status bits Number conversion: binary to/from

More information

Arithmetic Processing

Arithmetic Processing CS/EE 5830/6830 VLSI ARCHITECTURE Chapter 1 Basic Number Representations and Arithmetic Algorithms Arithmetic Processing AP = (operands, operation, results, conditions, singularities) Operands are: Set

More information

Arithmetic and Bitwise Operations on Binary Data

Arithmetic and Bitwise Operations on Binary Data Arithmetic and Bitwise Operations on Binary Data CSCI 2400: Computer Architecture ECE 3217: Computer Architecture and Organization Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides

More information

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column 1's column 10's column 100's column 1000's column 1's column 2's column 4's column 8's column Number Systems Decimal numbers 5374 10 = Binary numbers 1101 2 = Chapter 1 1's column 10's column 100's

More information

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Chapter 2 Bits, Data Types, and Operations Computer is a binary digital system. Digital system: finite number of symbols Binary (base two) system: has two states: 0 and 1 Basic unit of information is the

More information

COMP 122/L Lecture 2. Kyle Dewey

COMP 122/L Lecture 2. Kyle Dewey COMP 122/L Lecture 2 Kyle Dewey Outline Operations on binary values AND, OR, XOR, NOT Bit shifting (left, two forms of right) Addition Subtraction Twos complement Bitwise Operations Bitwise AND Similar

More information

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Chapter 2 Bits, Data Types, and Operations Original slides from Gregory Byrd, North Carolina State University Modified by Chris Wilcox, S. Rajopadhye Colorado State University How do we represent data

More information

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Instructor: Rob Bergen Applied Computer Science University of Winnipeg Announcements Website is up

More information

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer. Digital Logic 1 Data Representations 1.1 The Binary System The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer. The system we

More information

Representing Information. Bit Juggling. - Representing information using bits - Number representations. - Some other bits - Chapters 1 and 2.3,2.

Representing Information. Bit Juggling. - Representing information using bits - Number representations. - Some other bits - Chapters 1 and 2.3,2. Representing Information 0 1 0 Bit Juggling 1 1 - Representing information using bits - Number representations 1 - Some other bits 0 0 - Chapters 1 and 2.3,2.4 Motivations Computers Process Information

More information

Computer Organisation CS303

Computer Organisation CS303 Computer Organisation CS303 Module Period Assignments 1 Day 1 to Day 6 1. Write a program to evaluate the arithmetic statement: X=(A-B + C * (D * E-F))/G + H*K a. Using a general register computer with

More information

UNIT 7A Data Representation: Numbers and Text. Digital Data

UNIT 7A Data Representation: Numbers and Text. Digital Data UNIT 7A Data Representation: Numbers and Text 1 Digital Data 10010101011110101010110101001110 What does this binary sequence represent? It could be: an integer a floating point number text encoded with

More information

Numbers and Representations

Numbers and Representations Çetin Kaya Koç http://koclab.cs.ucsb.edu/teaching/cs192 koc@cs.ucsb.edu Çetin Kaya Koç http://koclab.cs.ucsb.edu Fall 2016 1 / 38 Outline Computational Thinking Representations of integers Binary and decimal

More information

Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8

Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8 Data Representation At its most basic level, all digital information must reduce to 0s and 1s, which can be discussed as binary, octal, or hex data. There s no practical limit on how it can be interpreted

More information

The type of all data used in a C (or C++) program must be specified

The type of all data used in a C (or C++) program must be specified The type of all data used in a C (or C++) program must be specified A data type is a description of the data being represented That is, a set of possible values and a set of operations on those values

More information

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014 Problem 1 (4 parts, 21 points) Encoders and Pass Gates Part A (8 points) Suppose the circuit below has the following input priority: I 1 > I 3 > I 0 > I 2. Complete the truth table by filling in the input

More information

Thus needs to be a consistent method of representing negative numbers in binary computer arithmetic operations.

Thus needs to be a consistent method of representing negative numbers in binary computer arithmetic operations. Signed Binary Arithmetic In the real world of mathematics, computers must represent both positive and negative binary numbers. For example, even when dealing with positive arguments, mathematical operations

More information

Signed umbers. Sign/Magnitude otation

Signed umbers. Sign/Magnitude otation Signed umbers So far we have discussed unsigned number representations. In particular, we have looked at the binary number system and shorthand methods in representing binary codes. With m binary digits,

More information

Fundamentals of Programming Session 2

Fundamentals of Programming Session 2 Fundamentals of Programming Session 2 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2013 Sharif University of Technology Outlines Programming Language Binary numbers Addition Subtraction

More information

MACHINE LEVEL REPRESENTATION OF DATA

MACHINE LEVEL REPRESENTATION OF DATA MACHINE LEVEL REPRESENTATION OF DATA CHAPTER 2 1 Objectives Understand how integers and fractional numbers are represented in binary Explore the relationship between decimal number system and number systems

More information

Octal and Hexadecimal Integers

Octal and Hexadecimal Integers Octal and Hexadecimal Integers CS 350: Computer Organization & Assembler Language Programming A. Why? Octal and hexadecimal numbers are useful for abbreviating long bitstrings. Some operations on octal

More information

Integer Encoding and Manipulation

Integer Encoding and Manipulation CSE 2421: Systems I Low-Level Programming and Computer Organization Integer Encoding and Manipulation Presentation D Study: Bryant Chapter 2.1 2.3 Gojko Babić 01-24-2018 Unsigned & Signed Integer Encoding

More information

CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation

CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation CS113: Lecture 3 Topics: Variables Data types Arithmetic and Bitwise Operators Order of Evaluation 1 Variables Names of variables: Composed of letters, digits, and the underscore ( ) character. (NO spaces;

More information

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems Decimal & Binary Representation Systems Decimal & binary are positional representation systems each position has a value: d*base i for example: 321 10 = 3*10 2 + 2*10 1 + 1*10 0 for example: 101000001

More information

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University. Data Representation ti and Arithmetic for Computers Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Questions What do you know about

More information

CS107, Lecture 3 Bits and Bytes; Bitwise Operators

CS107, Lecture 3 Bits and Bytes; Bitwise Operators CS107, Lecture 3 Bits and Bytes; Bitwise Operators reading: Bryant & O Hallaron, Ch. 2.1 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons Attribution

More information

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude Chapter 2 Positional number systems A positional number system represents numeric values as sequences of one or more digits. Each digit in the representation is weighted according to its position in the

More information

Number Systems and Computer Arithmetic

Number Systems and Computer Arithmetic Number Systems and Computer Arithmetic Counting to four billion two fingers at a time What do all those bits mean now? bits (011011011100010...01) instruction R-format I-format... integer data number text

More information

Wednesday, February 7, 2018

Wednesday, February 7, 2018 Wednesday, February 7, 2018 Topics for today The Pep/9 memory Four example programs The loader The assembly language level (Chapter 5) Symbolic Instructions Assembler directives Immediate mode and equate

More information

±M R ±E, S M CHARACTERISTIC MANTISSA 1 k j

±M R ±E, S M CHARACTERISTIC MANTISSA 1 k j ENEE 350 c C. B. Silio, Jan., 2010 FLOATING POINT REPRESENTATIONS It is assumed that the student is familiar with the discussion in Appendix B of the text by A. Tanenbaum, Structured Computer Organization,

More information

DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors. Data Representation Data Representation Goal: Store numbers, characters, sets, database records in the computer. What we got: Circuit that stores 2 voltages, one for logic 0 (0 volts) and one for logic

More information

Data Representation. DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

Data Representation. DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors. Data Representation Data Representation Goal: Store numbers, characters, sets, database records in the computer. What we got: Circuit that stores 2 voltages, one for logic ( volts) and one for logic (3.3

More information