Representation of Non Negative Integers

Size: px
Start display at page:

Download "Representation of Non Negative Integers"

Transcription

1 Representation of Non Negative Integers In each of one s complement and two s complement arithmetic, no special steps are required to represent a non negative integer. All conversions to the complement number systems begin with conversion to simple binary representation, often from decimal notation. The only issue with non negative integers is to insure that the number is not too large for the number of bits used in the representation. There are two ways to define this size limitation in the complement numbers system. 1. The most significant bit (leftmost) must be a 0 for non negative numbers. 2. For an N bit representation, the number must be less than 2 N 1. The biggest signed 8 bit integer is 2 7 1= 127. The biggest signed 16 bit integer is = Three 8 bit examples: 100 = = =

2 Negative Numbers and Subtraction The adders we designed can add only non-negative numbers If we can represent negative numbers, then subtraction is just the ability to add two numbers (one of which may be negative). We ll look at three different ways of representing signed numbers. How can we decide representation is better? The best one should result in the simplest and fastest operations. This is just like choosing a data structure in programming. We re mostly concerned with two particular operations: Negating a signed number, or converting x into -x. Adding two signed numbers, or computing x + y. So, we will compare the representation on how fast (and how easily) these operations can be done on them Subtraction (lvk) 1

3 Representation of Negative Numbers Sign Binary Integers (word length: n=4) Note: 1000 represent -0 in sign and magnitude system and -8 in 2 s complement system and -7 in 1 s complement system

4 Comparing the signed number systems Here are all the 4-bit numbers in the different systems. Positive numbers are the same in all three representations. Signed magnitude and one s complement have two ways of representing 0. This makes things more complicated. Two s complement has asymmetric ranges; there is one more negative number than positive number. Here, you can represent -8 but not +8. However, two s complement is preferred because it has only one 0, and its addition algorithm is the simplest. Decimal S.M. 1 s comp. 2 s comp Subtraction (lvk) 12

5 Ranges of the signed number systems How many negative and positive numbers can be represented in each of the different systems on the previous page? Unsigned Signed Magnitude One s complement Two s complement Smallest 0000 (0) 1111 (-7) 1000 (-7) 1000 (-8) Largest 1111 (15) 0111 (+7) 0111 (+7) 0111 (+7) In general, with n-bit numbers including the sign, the ranges are: Unsigned Signed Magnitude One s complement Two s complement Smallest 0 -(2 n-1-1) -(2 n-1-1) -2 n-1 Largest 2 n -1 +(2 n-1-1) +(2 n-1-1) +(2 n-1-1) Subtraction (lvk) 13

6 Converting signed numbers to decimal Convert to decimal, assuming this is a number in: (a) signed magnitude format (b) ones complement (c) two s complement Subtraction (lvk) 14

7 Example solution Convert to decimal, assuming this is a number in: Since the sign bit is 1, this is a negative number. The easiest way to find the magnitude is to convert it to a positive number. (a) signed magnitude format Negating the original number, , gives , which is +21 in decimal. So must represent -21. (b) ones complement Negating in ones complement yields = , so the original number must have been (c) two s complement Negating in two s complement gives = 11 10, which means = The most important point here is that a binary number has different meanings depending on which representation is assumed. Subtraction (lvk) 15

8 Two s Complement Arithmetic We now address the issue of representing integers as binary strings in a computer. There are four formats that have been used in the past; only one is of interest to us. The four formats are 1. Sign Magnitude 2. One s Complement 3. Two s Complement 4. Excess N, where N is some positive integer; say 127 for Excess 127. Sign magnitude representation is obsolete. Excess 127 representation is only used as part of floating point representations. If discussed at all, it will be in the context of the IEEE 754 standard. We focus on Two s complement, but discuss one s complement arithmetic as a mechanism for generating the two s complement.

9 Signed magnitude representation Humans use a signed-magnitude system: we add + or - in front of a magnitude to indicate the sign. We could do this in binary as well, by adding an extra sign bit to the front of our numbers. By convention: A 0 sign bit represents a positive number. A 1 sign bit represents a negative number. Examples: = (a 4-bit unsigned number) = (a positive number in 5-bit signed magnitude) = (a negative number in 5-bit signed magnitude) = 4 10 (a 4-bit unsigned number) = (a positive number in 5-bit signed magnitude) = (a negative number in 5-bit signed magnitude) Subtraction (lvk) 2

10 Two s complement Our final idea is two s complement. To negate a number, complement each bit (just as for ones complement) and then add 1. Examples: = (a 4-bit unsigned number) = (a positive number in 5-bit two s complement) = (a negative number in 5-bit ones complement) = (a negative number in 5-bit two s complement) = 4 10 (a 4-bit unsigned number) = (a positive number in 5-bit two s complement) = (a negative number in 5-bit ones complement) = (a negative number in 5-bit two s complement) Subtraction (lvk) 7

11 Taking the Two s Complement (Part 2) The recipe for taking the two s complement of a binary number is simple. 1. Take the one s complement of the number 2. Add 1 to that complement in 8 bit two s complement binary in 8 bit two s complement binary Represent +100 as an 8 bit number Take the one s complement Add is represented as in 8 bit two s complement binary in 8 bit two s complement binary Represent +22 as an 8 bit number Take the one s complement Add is represented as

12 Taking the Two s Complement (Part 3) +0in8 bit two s complement binary in8 bit two s complement binary Represent +0 as an 8 bit number Take the one s complement Add 1 1 Discard the high carry bit 0 is represented as Claim: 1in8 bit two s complement binary is and 128 in 8 bit two s complement binary in 8 bit two s complement binary in 8 bit two s complement binary Represent +127 as an 8 bit number Take the one s complement Add is represented as is one less than 127, so is represented as

13 Standard Ranges Here is the standard Java implementation of Two s Complement arithmetic. In general the range for N bit two s complement arithmetic is 2 N 1 to 2 N 1 1 Java Type Number of Bits Lower Limit Upper Limit byte short int long Log 10 (2) is about Log 10 (3) is about Log 10 (2 63 )isabout = Log 10 (9) = Log 10 (3 2 )=2 Log 10 (3) = = As > Log 10 (9), we concludethat2 63 is bigger than

14 Standard Values in N Bit Two s Complement Arithmetic (With Examples for 16 bit integers) 0 is represented by N zeroes is represented by N ones N 1 is represented by a 1 followed by (N 1) zeroes The student should memorize these patterns and not bother with standard conversion techniques when obtaining them. Technically speaking, the representation of 2 N 1 cannot be derived by standard means, as 2 N 1 cannot be represented.

15 Two s complement addition Negating a two s complement number takes a bit of work, but addition is much easier than with the other two systems. To find A + B, you just have to: Do unsigned addition on A and B, including their sign bits. Ignore any carry out. For example, to find , or (+7) + (-4): First add as unsigned numbers: Discard the carry out (1). The answer is 0011 (+3). Subtraction (lvk) 9

16 More about two s complement Two other equivalent ways to negate two s complement numbers: You can subtract an n-bit two s complement number from 2 n ( ) ( ) (+4 10 ) (-4 10 ) You can complement all of the bits to the left of the rightmost = (a positive number in two s complement) = (a negative number in two s complement) = (a positive number in two s complement) = (a negative number in two s complement) Often, people talk about taking the two s complement of a number. This is a confusing phrase, but it usually means to negate some number that s already in two s complement format. Subtraction (lvk) 8

17 Another two s complement example To further convince you that this works, let s try adding two negative numbers , or (-3) + (-2) in decimal. Adding the numbers gives 11011: Dropping the carry out (1) leaves us with the answer, 1011 (-5). Subtraction (lvk) 10

18 Addition of 2 s Complement Numbers Different cases in addition of 2 s complement numbers for n=4 Case 1: Addition of two positive numbers, sum < 2 n-1 Case 2: Addition of two positive numbers, sum > 2 n-1 Overflow since +11 requires 5 bits including sign

19 Addition of 2 s Complement Numbers Case 3: Addition of positive and negative numbers (negative number has greater magnitude) Case 4: Same as case 3 except positive number has greater magnitude the carry from the sign bit is ignored (NOT overflow)

20 Addition of 2 s Complement Numbers Case 5: Addition of two negative numbers, sum 2 n-1 the last carry is ignored (NOT overflow) Case 6: Addition of two negative numbers, sum > 2 n-1 Overflow since -11 requires 5 bits including sign

21 Signed overflow With two s complement and a 4-bit adder, for example, the largest representable decimal number is +7, and the smallest is -8. What if you try to compute 4 + 5, or (-4) + (-5)? (+4) (+5) (-7) (-4) (-5) (+7) We cannot just include the carry out to produce a five-digit result, as for unsigned addition. If we did, (-4) + (-5) would result in +23! Also, unlike the case with unsigned numbers, the carry out cannot be used to detect overflow. In the example on the left, the carry out is 0 but there is overflow. Conversely, there are situations where the carry out is 1 but there is no overflow. Subtraction (lvk) 17

22 Detecting signed overflow The easiest way to detect signed overflow is to look at all the sign bits (+4) (+5) (-7) (-4) (-5) (+7) Overflow occurs only in the two situations above: If you add two positive numbers and get a negative result. If you add two negative numbers and get a positive result. Overflow cannot occur if you add a positive number to a negative number. Do you see why? Subtraction (lvk) 18

23 Overflow: Busting the Arithmetic The range of 16 bit two s complement arithmetic is 32,768 to 32,767 Consider the following addition problem: Now + 24,576 (binary ) is well within the range What happened? We had a carry into the sign bit. This is overflow. The binary representation being used cannot handle the result. NOTE: This works as unsigned arithmetic. 24, ,576 = 49,152 = When we design a binary adder for N bit integers (N > 1), we shall address the standard method for detecting overflow.

24 Saturation Arithmetic Saturation arithmetic is applied to unsigned N bit integers. The unsigned range is 0 2 N 1. N=8 0 through 255 N=16 0 through N=32 0 through 4,294,967,295 Saturation arithmetic is commonly appliedto8 bit integers used in computer graphics. RULES: In addition, if the sum is greater than 2 N 1, set it to 2 N 1. In subtraction, if the number is less than 0, set it to 0. Examples (8 bit saturation arithmetic) = = = = =255 Result: Brightening a bright scene does not accidentally make it dark.

25 Sign extension In everyday life, decimal numbers are assumed to have an infinite number of 0s in front of them. This helps in lining up numbers. To subtract 231 and 3, for instance, you can imagine: You need to be careful in extending signed binary numbers, because the leftmost bit is the sign and not part of the magnitude. If you just add 0s in front, you might accidentally change a negative number into a positive one! For example, going from 4-bit to 8-bit numbers: 0101 (+5) should become (+5). But 1100 (-4) should become (-4). The proper way to extend a signed binary number is to replicate the sign bit, so the sign is preserved. Subtraction (lvk) 19

26 Signed Numbers are Sign-Extended to Infinity! Memorize this idea. It will save you every time when you are doing binary arithmetic by hand in twos complement is actually in twos complement is actually = This is overflow. But can you see it? Look again: = The sign of the result (1) is different than bit 3 (0). We cannot represent the result in 4 bits The sign of the result is extended to infinity Check this every time in your answers and you will always see the precision of the result (number of significant bits) very clearly. Sign-extend inputs to infinity Do the math on an infinite number of bits (conceptually) Truncate the result to the desired output type Subtraction (lvk) 20

27 Sign Extension In two s complement arithmetic, the leftmost bit is the sign bit. It is 1 for negative numbers 0fornon negative numbers Sign extension is the process of converting a N bit representation to alargerformat;e.g.,a16 bit number to a 32 bit number. Example: in 8 bit two s complement binary in 16 bit two s complement binary in 8 bit two s complement binary in 16 bit two s complement binary Rule just extend the sign bit to fill the new high order bits.

28 Subtraction summary A good representation for negative numbers makes subtraction hardware much easier to design. Two s complement is used most often (although signed magnitude shows up sometimes, such as in floating-point systems, which we ll discuss later). Using two s complement, we can build a subtractor with minor changes to the adder from last time. We can also make a single circuit which can both add and subtract. Overflow is still a problem, but signed overflow is very different from the unsigned overflow we mentioned last time. Sign extension is needed to properly lengthen negative numbers. After the midterm we ll use most of the ideas we ve seen so far to build an ALU an important part of a processor. Subtraction (lvk) 25

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

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation Complement Number Systems A complement number system is used to represent positive and negative integers A complement number system is based on a fixed length representation of numbers Pretend that integers

More information

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand Digital Arithmetic Digital Arithmetic: Operations and Circuits Dr. Farahmand Binary Arithmetic Digital circuits are frequently used for arithmetic operations Fundamental arithmetic operations on binary

More information

World Inside a Computer is Binary

World Inside a Computer is Binary C Programming 1 Representation of int data World Inside a Computer is Binary C Programming 2 Decimal Number System Basic symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Radix-10 positional number system. The radix

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

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

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

CS 261 Fall Mike Lam, Professor Integer Encodings

CS 261 Fall Mike Lam, Professor   Integer Encodings CS 261 Fall 2018 Mike Lam, Professor https://xkcd.com/571/ Integer Encodings Integers Topics C integer data types Unsigned encoding Signed encodings Conversions Integer data types in C99 1 byte 2 bytes

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

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

Binary Adders: Half Adders and Full Adders

Binary Adders: Half Adders and Full Adders Binary Adders: Half Adders and Full Adders In this set of slides, we present the two basic types of adders: 1. Half adders, and 2. Full adders. Each type of adder functions to add two binary bits. In order

More information

Numeric Encodings Prof. James L. Frankel Harvard University

Numeric Encodings Prof. James L. Frankel Harvard University Numeric Encodings Prof. James L. Frankel Harvard University Version of 10:19 PM 12-Sep-2017 Copyright 2017, 2016 James L. Frankel. All rights reserved. Representation of Positive & Negative Integral and

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

Logic, Words, and Integers

Logic, Words, and Integers Computer Science 52 Logic, Words, and Integers 1 Words and Data The basic unit of information in a computer is the bit; it is simply a quantity that takes one of two values, 0 or 1. A sequence of k bits

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

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example Appendix F Number Systems Binary Numbers Decimal notation represents numbers as powers of 10, for example 1729 1 103 7 102 2 101 9 100 decimal = + + + There is no particular reason for the choice of 10,

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

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,... Chapter 9 Computer Arithmetic Reading: Section 9.1 on pp. 290-296 Computer Representation of Data Groups of two-state devices are used to represent data in a computer. In general, we say the states are

More information

Floating Point Arithmetic

Floating Point Arithmetic Floating Point Arithmetic CS 365 Floating-Point What can be represented in N bits? Unsigned 0 to 2 N 2s Complement -2 N-1 to 2 N-1-1 But, what about? very large numbers? 9,349,398,989,787,762,244,859,087,678

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

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

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

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 CS 64 Lecture 2 Data Representation Reading: FLD 1.2-1.4 Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 ) + (1x10 0 ) 1010 10?= 1010 2?= 1

More information

CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29

CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29 CS 31: Introduction to Computer Systems 03: Binary Arithmetic January 29 WiCS! Swarthmore Women in Computer Science Slide 2 Today Binary Arithmetic Unsigned addition Subtraction Representation Signed magnitude

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

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

Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

Binary Addition. Add the binary numbers and and show the equivalent decimal addition. Binary Addition The rules for binary addition are 0 + 0 = 0 Sum = 0, carry = 0 0 + 1 = 0 Sum = 1, carry = 0 1 + 0 = 0 Sum = 1, carry = 0 1 + 1 = 10 Sum = 0, carry = 1 When an input carry = 1 due to a previous

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

Chapter 3 Data Representation

Chapter 3 Data Representation Chapter 3 Data Representation The focus of this chapter is the representation of data in a digital computer. We begin with a review of several number systems (decimal, binary, octal, and hexadecimal) and

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

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

Chapter 3: Arithmetic for Computers

Chapter 3: Arithmetic for Computers Chapter 3: Arithmetic for Computers Objectives Signed and Unsigned Numbers Addition and Subtraction Multiplication and Division Floating Point Computer Architecture CS 35101-002 2 The Binary Numbering

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

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

Introduction to Computer Science-103. Midterm

Introduction to Computer Science-103. Midterm Introduction to Computer Science-103 Midterm 1. Convert the following hexadecimal and octal numbers to decimal without using a calculator, showing your work. (6%) a. (ABC.D) 16 2748.8125 b. (411) 8 265

More information

Chapter 3: part 3 Binary Subtraction

Chapter 3: part 3 Binary Subtraction Chapter 3: part 3 Binary Subtraction Iterative combinational circuits Binary adders Half and full adders Ripple carry and carry lookahead adders Binary subtraction Binary adder-subtractors Signed binary

More information

Divide: Paper & Pencil

Divide: Paper & Pencil Divide: Paper & Pencil 1001 Quotient Divisor 1000 1001010 Dividend -1000 10 101 1010 1000 10 Remainder See how big a number can be subtracted, creating quotient bit on each step Binary => 1 * divisor or

More information

CS 64 Week 1 Lecture 1. Kyle Dewey

CS 64 Week 1 Lecture 1. Kyle Dewey CS 64 Week 1 Lecture 1 Kyle Dewey Overview Bitwise operation wrap-up Two s complement Addition Subtraction Multiplication (if time) Bitwise Operation Wrap-up Shift Left Move all the bits N positions to

More information

Representation of Numbers

Representation of Numbers Computer Architecture 10 Representation of Numbers Made with OpenOffice.org 1 Number encodings Additive systems - historical Positional systems radix - the base of the numbering system, the positive integer

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

Binary Representations and Arithmetic

Binary Representations and Arithmetic Binary Representations and Arithmetic 9--26 Common number systems. Base : decimal Base 2: binary Base 6: hexadecimal (memory addresses) Base 8: octal (obsolete computer systems) Base 64 (email attachments,

More information

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers Real Numbers We have been studying integer arithmetic up to this point. We have discovered that a standard computer can represent a finite subset of the infinite set of integers. The range is determined

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

IEEE Standard for Floating-Point Arithmetic: 754

IEEE Standard for Floating-Point Arithmetic: 754 IEEE Standard for Floating-Point Arithmetic: 754 G.E. Antoniou G.E. Antoniou () IEEE Standard for Floating-Point Arithmetic: 754 1 / 34 Floating Point Standard: IEEE 754 1985/2008 Established in 1985 (2008)

More information

Number Systems (2.1.1)

Number Systems (2.1.1) Number Systems (2.1.1) Concept of a register. Operations of register, Complementation, Ranges, Left and right shifts, Addition of two binary number, Numerical overflow, 2 s complement representation, Binary

More information

Number representations

Number representations Number representations Number bases Three number bases are of interest: Binary, Octal and Hexadecimal. We look briefly at conversions among them and between each of them and decimal. Binary Base-two, or

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

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

Number Systems. Both numbers are positive

Number Systems. Both numbers are positive Number Systems Range of Numbers and Overflow When arithmetic operation such as Addition, Subtraction, Multiplication and Division are performed on numbers the results generated may exceed the range of

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

Chapter 1 Review of Number Systems

Chapter 1 Review of Number Systems 1.1 Introduction Chapter 1 Review of Number Systems Before the inception of digital computers, the only number system that was in common use is the decimal number system which has a total of 10 digits

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

CO212 Lecture 10: Arithmetic & Logical Unit

CO212 Lecture 10: Arithmetic & Logical Unit CO212 Lecture 10: Arithmetic & Logical Unit Shobhanjana Kalita, Dept. of CSE, Tezpur University Slides courtesy: Computer Architecture and Organization, 9 th Ed, W. Stallings Integer Representation For

More information

8/27/2016. ECE 120: Introduction to Computing. Graphical Illustration of Modular Arithmetic. Representations Must be Unambiguous

8/27/2016. ECE 120: Introduction to Computing. Graphical Illustration of Modular Arithmetic. Representations Must be Unambiguous University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 120: Introduction to Computing Signed Integers and 2 s Complement Strategy: Use Common Hardware for Two Representations

More information

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal Basic Definition REPRESENTING INTEGER DATA Englander Ch. 4 An integer is a number which has no fractional part. Examples: -2022-213 0 1 514 323434565232 Unsigned and -Coded Decimal BCD: -Coded Decimal

More information

Chapter Three. Arithmetic

Chapter Three. Arithmetic Chapter Three 1 Arithmetic Where we've been: Performance (seconds, cycles, instructions) Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's up ahead: Implementing

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

4/8/17. Admin. Assignment 5 BINARY. David Kauchak CS 52 Spring 2017

4/8/17. Admin. Assignment 5 BINARY. David Kauchak CS 52 Spring 2017 4/8/17 Admin! Assignment 5 BINARY David Kauchak CS 52 Spring 2017 Diving into your computer Normal computer user 1 After intro CS After 5 weeks of cs52 What now One last note on CS52 memory address binary

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

Principles of Computer Architecture. Chapter 3: Arithmetic

Principles of Computer Architecture. Chapter 3: Arithmetic 3-1 Chapter 3 - Arithmetic Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 3: Arithmetic 3-2 Chapter 3 - Arithmetic 3.1 Overview Chapter Contents 3.2 Fixed Point Addition

More information

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012 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

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

COMPUTER ARITHMETIC (Part 1)

COMPUTER ARITHMETIC (Part 1) Eastern Mediterranean University School of Computing and Technology ITEC255 Computer Organization & Architecture COMPUTER ARITHMETIC (Part 1) Introduction The two principal concerns for computer arithmetic

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 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

Level ISA3: Information Representation

Level ISA3: Information Representation Level ISA3: Information Representation 1 Information as electrical current At the lowest level, each storage unit in a computer s memory is equipped to contain either a high or low voltage signal Each

More information

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng Slide Set 1 for ENEL 339 Fall 2014 Lecture Section 02 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Fall Term, 2014 ENEL 353 F14 Section

More information

Digital Systems. John SUM Institute of Technology Management National Chung Hsing University Taichung, ROC. December 6, 2012

Digital Systems. John SUM Institute of Technology Management National Chung Hsing University Taichung, ROC. December 6, 2012 Digital Systems John SUM Institute of Technology Management National Chung Hsing University Taichung, ROC December 6, 2012 Contents 1 Logic Gates 3 1.1 Logic Gate............................. 3 1.2 Truth

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

Integers and Floating Point

Integers and Floating Point CMPE12 More about Numbers Integers and Floating Point (Rest of Textbook Chapter 2 plus more)" Review: Unsigned Integer A string of 0s and 1s that represent a positive integer." String is X n-1, X n-2,

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

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010 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

Introduction to Computers and Programming. Numeric Values

Introduction to Computers and Programming. Numeric Values Introduction to Computers and Programming Prof. I. K. Lundqvist Lecture 5 Reading: B pp. 47-71 Sept 1 003 Numeric Values Storing the value of 5 10 using ASCII: 00110010 00110101 Binary notation: 00000000

More information

Number Systems. Readings: , Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs

Number Systems. Readings: , Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Number Systems Readings: 3-3.3.3, 3.3.5 Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches Missing: Way to implement

More information

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar Data Representation COE 30 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals Presentation Outline Positional Number

More information

CS101 Lecture 04: Binary Arithmetic

CS101 Lecture 04: Binary Arithmetic CS101 Lecture 04: Binary Arithmetic Binary Number Addition Two s complement encoding Briefly: real number representation Aaron Stevens (azs@bu.edu) 25 January 2013 What You ll Learn Today Counting in binary

More information

Binary Addition & Subtraction. Unsigned and Sign & Magnitude numbers

Binary Addition & Subtraction. Unsigned and Sign & Magnitude numbers Binary Addition & Subtraction Unsigned and Sign & Magnitude numbers Addition and subtraction of unsigned or sign & magnitude binary numbers by hand proceeds exactly as with decimal numbers. (In fact this

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

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

Chapter 1. Digital Systems and Binary Numbers

Chapter 1. Digital Systems and Binary Numbers Chapter 1. Digital Systems and Binary Numbers Tong In Oh 1 1.1 Digital Systems Digital age Characteristic of digital system Generality and flexibility Represent and manipulate discrete elements of information

More information

EE 109 Unit 6 Binary Arithmetic

EE 109 Unit 6 Binary Arithmetic EE 109 Unit 6 Binary Arithmetic 1 2 Semester Transition Point 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

Chapter 10 - Computer Arithmetic

Chapter 10 - Computer Arithmetic Chapter 10 - Computer Arithmetic Luis Tarrataca luis.tarrataca@gmail.com CEFET-RJ L. Tarrataca Chapter 10 - Computer Arithmetic 1 / 126 1 Motivation 2 Arithmetic and Logic Unit 3 Integer representation

More information

Computer Architecture and Organization

Computer Architecture and Organization 3-1 Chapter 3 - Arithmetic Computer Architecture and Organization Miles Murdocca and Vincent Heuring Chapter 3 Arithmetic 3-2 Chapter 3 - Arithmetic Chapter Contents 3.1 Fixed Point Addition and Subtraction

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

Floating Point Arithmetic

Floating Point Arithmetic Floating Point Arithmetic Clark N. Taylor Department of Electrical and Computer Engineering Brigham Young University clark.taylor@byu.edu 1 Introduction Numerical operations are something at which digital

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

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

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

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

Introduction to Scientific Computing Lecture 1

Introduction to Scientific Computing Lecture 1 Introduction to Scientific Computing Lecture 1 Professor Hanno Rein Last updated: September 10, 2017 1 Number Representations In this lecture, we will cover two concept that are important to understand

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

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

Computer Architecture Set Four. Arithmetic

Computer Architecture Set Four. Arithmetic Computer Architecture Set Four Arithmetic Arithmetic Where we ve been: Performance (seconds, cycles, instructions) Abstractions: Instruction Set Architecture Assembly Language and Machine Language What

More information

CS61c Midterm Review (fa06) Number representation and Floating points From your friendly reader

CS61c Midterm Review (fa06) Number representation and Floating points From your friendly reader CS61c Midterm Review (fa06) Number representation and Floating points From your friendly reader Number representation (See: Lecture 2, Lab 1, HW#1) KNOW: Kibi (2 10 ), Mebi(2 20 ), Gibi(2 30 ), Tebi(2

More information

Lecture 6: Signed Numbers & Arithmetic Circuits. BCD (Binary Coded Decimal) Points Addressed in this Lecture

Lecture 6: Signed Numbers & Arithmetic Circuits. BCD (Binary Coded Decimal) Points Addressed in this Lecture Points ddressed in this Lecture Lecture 6: Signed Numbers rithmetic Circuits Professor Peter Cheung Department of EEE, Imperial College London (Floyd 2.5-2.7, 6.1-6.7) (Tocci 6.1-6.11, 9.1-9.2, 9.4) Representing

More information

CHAPTER 1 Numerical Representation

CHAPTER 1 Numerical Representation CHAPTER 1 Numerical Representation To process a signal digitally, it must be represented in a digital format. This point may seem obvious, but it turns out that there are a number of different ways to

More information

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC CHAPTER V-1 CHAPTER V CHAPTER V NUMBER SYSTEMS AND ARITHMETIC CHAPTER V-2 NUMBER SYSTEMS RADIX-R REPRESENTATION Decimal number expansion 73625 10 = ( 7 10 4 ) + ( 3 10 3 ) + ( 6 10 2 ) + ( 2 10 1 ) +(

More information

Computer (Literacy) Skills. Number representations and memory. Lubomír Bulej KDSS MFF UK

Computer (Literacy) Skills. Number representations and memory. Lubomír Bulej KDSS MFF UK Computer (Literacy Skills Number representations and memory Lubomír Bulej KDSS MFF UK Number representations? What for? Recall: computer works with binary numbers Groups of zeroes and ones 8 bits (byte,

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

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