# Signed umbers. Sign/Magnitude otation

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 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, we can represent the 2 m unique patterns, from to When we try to represent signed quantities in the same m digits, we still only have 2 m patterns to work with. Unless we increase the number of digits available (i.e. make m larger), the representation of signed numbers will involve dividing up these 2 m patterns into positive and negative portions. Sign/Magnitude is the simplest way to represent signed numbers, but the most common is a modification to sign/magnitude called two s complement. Sign/Magnitude otation Sign/magnitude notation is the simplest and one of the most obvious methods of encoding positive and negative numbers. Assign the leftmost (most significant) bit to be the sign bit. If the sign bit is 0, this means the number is positive. If the sign bit is 1, then the number is negative. The remaining m-1 bits are used to represent the magnitude of the binary number in the unsigned binary notation. Example using 4 bits: Binary Value Looking at the list you should notice an immediate peculiarity; there are two representations for zero! There is positive zero, and negative zero. This can cause complications for computers checking numbers for equality. Normally one can just compare all the bits between two numbers to see if they are the same. But now we will need a special case for zero, to check for the two different representations. More significant though, is if we perform addition on numbers in this representation, we don t get the correct answer (e.g = = 1010 which is -2, not 0).

2 Radix Complementation Two s Complement In two s complement, positive integers are represented the same was as sign magnitude (or regular unsigned binary) where the leftmost bit is 0: Binary Two s Complement Value Using four bits, the largest positive number we can represent is +7 since the first bit must be a 0 to denote positive. For a negative value for A, the sign bit, A n-1 is one instead of zero. We would like to assign the negative integers to the available bit patterns in a way that facilitates straightforward arithmetic. A method that does this is to count backwards where 1111 represents -1, 1110 represents -2, etc. This can be visualized in the figure below:

3 This representation has the benefit that if we start at any number on the circle, we can add positive k (or subtract negative k) from that number by moving k position clockwise or counterclockwise. If an arithmetic operation results in traversal of the point where the endpoints are joined, an incorrect answer is given. However, we are guaranteed that if we add a positive and a negative value together, we will result in a value that is possible to represent using the number of bits available. A complete binary table for four bits is shown below: Binary Two s Comp Value Binary Two Comp Note that we no longer have two representations for zero; we can represent down to -8 and up to +7. To summarize, two s complement lets us have only one representation for zero and allows us to easily perform arithmetic operations without special cases for sign bits. Shortcut for two s complement If we are given a decimal value, A, that we want to represent in two s complement, there is an easy way to do it: 1. If A is positive, represent it using the sign-magnitude representation. The leftmost bit must be 0, and the remaining bits are the binary for the integer. Be careful there are enough bits available to represent the number. 2. If A is negative, first represent in binary +A. a. Flip all the 1 s to 0 s and the 0 s to 1 s b. Add 1 to the result using unsigned binary notation Given a binary value in two s complement to compute its value in decimal: 1. If the leftmost bit is 0, the number is positive. Compute the magnitude as an unsigned binary number. 2. If the leftmost bit is 1, the number is negative. a. Flip all the 1 s to 0 s and the 0 s to 1 s b. Add 1 to the result using unsigned binary notation c. Compute the value as if it were an unsigned binary value, say it is B. This is the magnitude of the negative number. d. The actual value is -B

4 Examples: Assume that m = 5, i.e. we have 5 bits available to represent our values. What is 5 (decimal) in two s complement? +5 in unsigned binary is Flip the bits to get Now add 1: The answer is What is 7 (decimal) in two s complement? +7 in unsigned binary is Flip the bits to get Now add 1: Note that as m changes, we get different bit strings for negative numbers. What is the decimal value of the two s complement binary value 11100? Flip bits: Add one: This is 4, so the answer is 4 If the computer displays the hexadecimal number 1D, with m=8, what is this in decimal? 1D in binary is It starts with 0, so it is positive. DON T FLIP ANY BITS! We just convert this as unsigned binary: = 29 in decimal Arithmetic on Two s Complement Values Learning the rules of binary arithmetic is much easier than learning the rules of decimal arithmetic. Instead of memorizing 10x10 addition and subtraction tables, you only need to learn a 2x2 table: * * includes a carry to the next column

6 Example: What is the two s complement of 0? flip the bits = Add 1 and we get Since we ignore the carry bit, we end up with just That is, 0 and 0 are represented the same way in our system (yay!) Example: What is , using 5 bits? = 00101, 14 = If we didn t have the convention that the first bit indicates the sign, this would be 19 in unsigned binary. But we are using two s complement, so this number would be: Flip bits: 01100, Add 1: = 13 giving 13 Obviously, 5 plus 14 is not 13. What is wrong? We have encountered what is called an overflow condition. We must be warned that this condition has occurred so that we do not improperly try to use the result that is produced. All computers have an overflow register that is turned on if the previous arithmetic operation resulted in an overflow condition. Fortunately, it is easy to check for the overflow condition. We simply check to see if we are adding two positive numbers. If the result is a negative number, then there was an overflow. You cannot generate an overflow when adding a positive and negative quantity. In a similar fashion, if we add two negative numbers and end up with a positive number, we have also encountered overflow. To summarize, the results of an addition A + B are: A + B with any carries discarded Carry register = 0 or 1 if there was a carry Overflow register = 0 or 1 if there was an overflow

7 Performing Subtraction In order to do subtraction, hardware designers do not like to require extra hardware. Instead of separate circuits for subtraction, subtraction is performed by using addition with a negative number. That is: D = Y X Is computed by: D = -X + Y To compute X, we simply perform the process of flipping the bits on X and then adding 1, giving us the negative of X. We then perform the addition routine which is identical to what we previously discussed. Storing Fractions So far we have discussed signed and unsigned number representations. But how do we represent fractions? For example, we also need a way to represent a number like This is done based on scientific notation and is called floating point notation. Converting from Decimal to Binary Let s say that we want to convert into binary. The first task is to convert the number 252 into binary. We already know how to do this, we just divide 252 by 2 and keep the remainders, repeating the process with the non-fractional part. 252 = The next step is to convert into binary. To do this, instead of dividing by 2, we multiply by 2. Each time we multiply, record whatever is to the left of the decimal place after the operation. The first number becomes the leftmost bit, and the final number will be the rightmost bit. We then repeat this process using whatever is to the right of the decimal place * 2 = as leftmost bit * 2 = as the next bit * 2 = * 2 = * 2 = * 2 = Upon hitting 0, we re finished. The binary representation of this number is then:

8 Exercise: What is in binary? What is 0.1 in binary? Note that with the last example, we could continue forever. In practice, we continue the process until we reach the precision desired to represent the number. Also note that if we wanted to use this process on something other than base 2, we would just multiply by whatever base we were interested in (e.g., base 16). Converting Binary to Decimal Given a floating point number in binary like , how do we convert this back to decimal? The process is almost identical to the process for unsigned binary. The stuff to the left of the decimal point is the same: 1100 = 0 * * * *2 3 = 4+8 = 12 For the fractional part, we multiply and sum each bit, but starting with 2-1 power and continuing up to 2-2, 2-3, etc Recall that 2-1 is just 1/2, 2-2 is 1/4, 2-3 is 1/8, etc. Summing this up gives us: 0 * * * *2-4 +0*2-5 +1*2-6 = 1 / / / 64 = = Putting these together gives us Exercise: What is in decimal?

9 Scientific otation What we ve described is conceptually how to convert fractions from decimal to binary, but typically the data isn t stored in the computer in the same format. First we need to normalize the data, using scientific notation. Consider the decimal number First we need to determine which digits are significant. The formal rules for significant digits is: 1. A nonzero digit is always significant 2. The digit 0 is never significant when it precedes nonzero digits Using these rules, we can discard the initial 0 leaving us with Notice that we kept the trailing zeros; they may or may not be significant. Without more information we can t tell if we want precisely , or if perhaps is all we knew and the extra zeros are padding. To represent this in scientific notation, we move the decimal point to the position immediately to the right of the leftmost significant digit, and multiply by the correct factor of 10 to get back the original value: * 10 2 In this case, we moved the decimal point two places to the left, so we multiply by If we had a fraction we would do the opposite and multiply by a fraction of 10: = * 10-3 We can apply the same process to binary fractions, but use powers of 2 instead of powers of 10. Say that we have the binary value Converting this to scientific notation results in: * 2 2 Similarly, converted to scientific notation results in: 1.00 * 2-3 Exercise: What is in scientific notation?

10 Floating Point Representation Let s describe a simple format for storing floating point numbers. In practice, a different (but similar in principle) format called IEEE 754 is used in which 32 bits store a floating point value. In our example, we ll use 16 bits. To represent a floating point number, first convert it to binary scientific notation. For example, let s say that we end up with * 2 3. In general terms, this value is: (Sign) * (Mantissa) * 2 (exponent) In storing this value, by default, we will assume that the power is 2. To get this value back, we will need to store the , the sign using a sign bit, and then the exponent 3. The pieces that we must store are the: Sign Exponent (the 3) Mantissa (the part) The format we will use for our 16 bit format is: S EEEEE MMMMMMMMMM bit is allocated to the sign field (the leftmost bit). 5 bits are allocated to store the exponent field. 10 bits are allocated to store the mantissa field. Sign Field This is just a sign bit, like we used with signed binary numbers. It is either 0 or 1. 0 indicates a positive number, and 1 indicates a negative number. For our example number of * 2 3, this is positive so the sign bit would hold a 0. Exponent Field The exponent section is five bits long. In our case let s just store an integer using two s complement. In the IEEE format, a different notation (biased or excess notation) is used. For our example number of * 2 3 the exponent is 3, so we store for the exponent field.

11 Mantissa Field The mantissa section stores the rest of the floating point number. Since the power of 2 is implicit, all that is left to store are the significant digits of the number to represent. In the case of our example of * 2 3 this corresponds to the part. Putting everything together we have: Sign = 0 Exponent = Mantissa = Or: Grouping in 4 bits each we can express this succinctly as a hex number: = 0D4B Precision Precision refers to the number of bits that we can store in the mantissa. The more bits we have, the more precise the value we can represent. One way we can increase the precision slightly is by dropping the leftmost 1 of the mantissa. We can drop this bit because it will always be there in scientific notation. In calculating the floating point value we would have to insert the 1 back in. In our example we won t use this hidden bit but it is used in practice. Let s look at the range of values we can store in our floating point representation. With 5 bits for an exponent, we can represent exponents using our two s complement notation from = -16 to = +15 So the smallest value we can store is 1.0 * 2-16 (pretty small!) and the biggest value we can store is * If we expand this by moving the decimal point 15 places to the right then we get: = What s the second largest value we could store? * 2 15 = = This means that our floating point number format can t exactly store any value between and This problem is more significant with larger numbers than with

12 smaller numbers. We can alleviate the problem by using more bits for the mantissa, but ultimately all floating point number formats suffer from this problem. In contrast, consider a 16 bit unsigned integer. It can store values from 0 to 2 16 or There are also exactly different bit patterns. So using 16 bits for just integers can exactly represent all the values between and Of course, it can t represent floating point values like ½ or In the unsigned integer format, every one of the bit patterns is used to represent an integer. In the floating point format, there are still only bit patterns available. Some of those bit patterns are used to represent floating point numbers, so we lose the ability to represent some integers. It turns out we lose more large integers than small ones.

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

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

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

### Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

Floating-point Arithmetic Reading: pp. 312-328 Floating-Point Representation Non-scientific floating point numbers: A non-integer can be represented as: 2 4 2 3 2 2 2 1 2 0.2-1 2-2 2-3 2-4 where you sum

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

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

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

### FLOATING POINT NUMBERS

FLOATING POINT NUMBERS Robert P. Webber, Longwood University We have seen how decimal fractions can be converted to binary. For instance, we can write 6.25 10 as 4 + 2 + ¼ = 2 2 + 2 1 + 2-2 = 1*2 2 + 1*2

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

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

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

### ±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,

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

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

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

### Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction

1 Floating Point The World is Not Just Integers Programming languages support numbers with fraction Called floating-point numbers Examples: 3.14159265 (π) 2.71828 (e) 0.000000001 or 1.0 10 9 (seconds in

### unused unused unused unused unused unused

BCD numbers. In some applications, such as in the financial industry, the errors that can creep in due to converting numbers back and forth between decimal and binary is unacceptable. For these applications

### Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Instructor: Nicole Hynes nicole.hynes@rutgers.edu 1 Fixed Point Numbers Fixed point number: integer part

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

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

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

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

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

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

### Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

Chapter 03: Computer Arithmetic Lesson 09: Arithmetic using floating point numbers Objective To understand arithmetic operations in case of floating point numbers 2 Multiplication of Floating Point Numbers

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

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

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

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

### Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

N Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as: a n a a a The value of this number is given by: = a n Ka a a a a a

### CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

CS 265 Computer Architecture Wei Lu, Ph.D., P.Eng. 1 Part 1: Data Representation Our goal: revisit and re-establish fundamental of mathematics for the computer architecture course Overview: what are bits

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

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

### Floating Point Numbers. Lecture 9 CAP

Floating Point Numbers Lecture 9 CAP 3103 06-16-2014 Review of Numbers Computers are made to deal with numbers What can we represent in N bits? 2 N things, and no more! They could be Unsigned integers:

### UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS

UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS (09 periods) Computer Arithmetic: Data Representation, Fixed Point Representation, Floating Point Representation, Addition and

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

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

### Floating Point Representation. CS Summer 2008 Jonathan Kaldor

Floating Point Representation CS3220 - Summer 2008 Jonathan Kaldor Floating Point Numbers Infinite supply of real numbers Requires infinite space to represent certain numbers We need to be able to represent

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

### Excerpt from "Art of Problem Solving Volume 1: the Basics" 2014 AoPS Inc.

Chapter 5 Using the Integers In spite of their being a rather restricted class of numbers, the integers have a lot of interesting properties and uses. Math which involves the properties of integers is

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

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

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

### Math 340 Fall 2014, Victor Matveev. Binary system, round-off errors, loss of significance, and double precision accuracy.

Math 340 Fall 2014, Victor Matveev Binary system, round-off errors, loss of significance, and double precision accuracy. 1. Bits and the binary number system A bit is one digit in a binary representation

### Chapter 2 Data Representations

Computer Engineering Chapter 2 Data Representations Hiroaki Kobayashi 4/21/2008 4/21/2008 1 Agenda in Chapter 2 Translation between binary numbers and decimal numbers Data Representations for Integers

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

### ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

ECE 550D Fundamentals of Computer Systems and Engineering Fall 2017 Combinational Logic Prof. John Board Duke University Slides are derived from work by Profs. Tyler Bletsch and Andrew Hilton (Duke) Last

### Data Representations & Arithmetic Operations

Data Representations & Arithmetic Operations Hiroaki Kobayashi 7/13/2011 7/13/2011 Computer Science 1 Agenda Translation between binary numbers and decimal numbers Data Representations for Integers Negative

### D I G I T A L C I R C U I T S E E

D I G I T A L C I R C U I T S E E Digital Circuits Basic Scope and Introduction This book covers theory solved examples and previous year gate question for following topics: Number system, Boolean algebra,

### Divisibility Rules and Their Explanations

Divisibility Rules and Their Explanations Increase Your Number Sense These divisibility rules apply to determining the divisibility of a positive integer (1, 2, 3, ) by another positive integer or 0 (although

### Chapter 4: Data Representations

Chapter 4: Data Representations Integer Representations o unsigned o sign-magnitude o one's complement o two's complement o bias o comparison o sign extension o overflow Character Representations Floating

### The ALU consists of combinational logic. Processes all data in the CPU. ALL von Neuman machines have an ALU loop.

CS 320 Ch 10 Computer Arithmetic The ALU consists of combinational logic. Processes all data in the CPU. ALL von Neuman machines have an ALU loop. Signed integers are typically represented in sign-magnitude

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

### 8/30/2016. In Binary, We Have A Binary Point. ECE 120: Introduction to Computing. Fixed-Point Representations Support Fractions

University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 120: Introduction to Computing Fixed- and Floating-Point Representations In Binary, We Have A Binary Point Let

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

### Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

Numeral Systems -Numeral System -Positional systems -Decimal -Binary -Octal Subjects: Introduction A numeral system (or system of numeration) is a writing system for expressing numbers, that is a mathematical

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

### Number Systems Using and Converting Between Decimal, Binary, Octal and Hexadecimal Number Systems

Number Systems Using and Converting Between Decimal, Binary, Octal and Hexadecimal Number Systems In everyday life, we humans most often count using decimal or base-10 numbers. In computer science, it

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

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

### Computer Architecture and Organization. Chapter 2 Data Representation!

2-1! Chapter 2 - Data Representation! Computer Architecture and Organization Miles Murdocca and Vincent Heuring! Chapter 2 Data Representation! 2-2! Chapter 2 - Data Representation! Chapter Contents! 2.1

### ecture 25 Floating Point Friedland and Weaver Computer Science 61C Spring 2017 March 17th, 2017

ecture 25 Computer Science 61C Spring 2017 March 17th, 2017 Floating Point 1 New-School Machine Structures (It s a bit more complicated!) Software Hardware Parallel Requests Assigned to computer e.g.,

### Set Theory in Computer Science. Binary Numbers. Base 10 Number. What is a Number? = Binary Number Example

Set Theory in Computer Science Binary Numbers Part 1B Bit of This and a Bit of That What is a Number? Base 10 Number We use the Hindu-Arabic Number System positional grouping system each position is a

### Lecture Notes: Floating-Point Numbers

Lecture Notes: Floating-Point Numbers CS227-Scientific Computing September 8, 2010 What this Lecture is About How computers represent numbers How this affects the accuracy of computation Positional Number

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

### A Level Computing. Contents. For the Exam:

A Level Computing Contents For the Exam:... 1 Revision of Binary... 2 Computing Mathematics Revision... 2 Binary Addition/Subtraction revision... 3 BCD... 3 Sign and Magnitude... 4 2 s Compliment... 4

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

### Table : IEEE Single Format ± a a 2 a 3 :::a 8 b b 2 b 3 :::b 23 If exponent bitstring a :::a 8 is Then numerical value represented is ( ) 2 = (

Floating Point Numbers in Java by Michael L. Overton Virtually all modern computers follow the IEEE 2 floating point standard in their representation of floating point numbers. The Java programming language

### Computer Number Systems Supplement

Computer Number Systems Supplement Dr. Ken Hoganson, All Rights Reserved. SUPPLEMENT CONTENTS S.1 Decimal System: Powers-of-the-Base 2 S.2 Converting to Binary: Division/Remainder Algorithm. 3 S.3 Binary

### 3.5 Floating Point: Overview

3.5 Floating Point: Overview Floating point (FP) numbers Scientific notation Decimal scientific notation Binary scientific notation IEEE 754 FP Standard Floating point representation inside a computer

### Numeric Precision 101

www.sas.com > Service and Support > Technical Support TS Home Intro to Services News and Info Contact TS Site Map FAQ Feedback TS-654 Numeric Precision 101 This paper is intended as a basic introduction

### 3.1 DATA REPRESENTATION (PART C)

3.1 DATA REPRESENTATION (PART C) 3.1.3 REAL NUMBERS AND NORMALISED FLOATING-POINT REPRESENTATION In decimal notation, the number 23.456 can be written as 0.23456 x 10 2. This means that in decimal notation,

### CS321. Introduction to Numerical Methods

CS31 Introduction to Numerical Methods Lecture 1 Number Representations and Errors Professor Jun Zhang Department of Computer Science University of Kentucky Lexington, KY 40506 0633 August 5, 017 Number

### CHAPTER 2 Data Representation in Computer Systems

CHAPTER 2 Data Representation in Computer Systems 2.1 Introduction 37 2.2 Positional Numbering Systems 38 2.3 Decimal to Binary Conversions 38 2.3.1 Converting Unsigned Whole Numbers 39 2.3.2 Converting

### CSE 140 Homework One

CSE 140 Homewor One June 29, 2009 Only Problem Set Part B will be graded. Turn in only Problem Set Part B which will be due on July 13, 2009 (Monday) at 3:00pm. 1 Problem Set Part A textboo 1.3 textboo

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Prof. Gurindar Sohi TAs: Lisa Ossian, Minsub Shin, Sujith Surendran Midterm Examination 1 In Class (50 minutes) Wednesday,

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

### Representing numbers on the computer. Computer memory/processors consist of items that exist in one of two possible states (binary states).

Representing numbers on the computer. Computer memory/processors consist of items that exist in one of two possible states (binary states). These states are usually labeled 0 and 1. Each item in memory

### Chapter 3 Arithmetic for Computers (Part 2)

Department of Electr rical Eng ineering, Chapter 3 Arithmetic for Computers (Part 2) 王振傑 (Chen-Chieh Wang) ccwang@mail.ee.ncku.edu.tw ncku edu Depar rtment of Electr rical Eng ineering, Feng-Chia Unive

### CS/EE1012 INTRODUCTION TO COMPUTER ENGINEERING SPRING 2013 HOMEWORK I. Solve all homework and exam problems as shown in class and sample solutions

CS/EE2 INTRODUCTION TO COMPUTER ENGINEERING SPRING 23 DUE : February 22, 23 HOMEWORK I READ : Related portions of the following chapters : È Chapter È Chapter 2 È Appendix E ASSIGNMENT : There are eight

### Binary, Hexadecimal and Octal number system

Binary, Hexadecimal and Octal number system Binary, hexadecimal, and octal refer to different number systems. The one that we typically use is called decimal. These number systems refer to the number of

### Floating Point Numbers

Floating Point Numbers Summer 8 Fractional numbers Fractional numbers fixed point Floating point numbers the IEEE 7 floating point standard Floating point operations Rounding modes CMPE Summer 8 Slides

### CREATING FLOATING POINT VALUES IN MIL-STD-1750A 32 AND 48 BIT FORMATS: ISSUES AND ALGORITHMS

CREATING FLOATING POINT VALUES IN MIL-STD-1750A 32 AND 48 BIT FORMATS: ISSUES AND ALGORITHMS Jeffrey B. Mitchell L3 Communications, Telemetry & Instrumentation Division Storm Control Systems ABSTRACT Experimentation

### Computer Systems C S Cynthia Lee

Computer Systems C S 1 0 7 Cynthia Lee 2 Today s Topics LECTURE: Floating point! Real Numbers and Approximation MATH TIME! Some preliminary observations on approximation We know that some non-integer numbers

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

### Digital Fundamentals

Digital Fundamentals Tenth Edition Floyd Chapter 1 Modified by Yuttapong Jiraraksopakun Floyd, Digital Fundamentals, 10 th 2008 Pearson Education ENE, KMUTT ed 2009 Analog Quantities Most natural quantities

### Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit

Announcements Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit Quiz 2 Monday on Number System Conversions

### What Every Programmer Should Know About Floating-Point Arithmetic

What Every Programmer Should Know About Floating-Point Arithmetic Last updated: October 15, 2015 Contents 1 Why don t my numbers add up? 3 2 Basic Answers 3 2.1 Why don t my numbers, like 0.1 + 0.2 add

### CHAPTER 2 Data Representation in Computer Systems

CHAPTER 2 Data Representation in Computer Systems 2.1 Introduction 37 2.2 Positional Numbering Systems 38 2.3 Decimal to Binary Conversions 38 2.3.1 Converting Unsigned Whole Numbers 39 2.3.2 Converting

### TUTORIAL -1 COMPUTER ORGANISATION TIT-402

TUTORIAL -1 COMPUTER ORGANISATION TIT-402 Q1.(43) 10 = (? ) 2 s (GATE 2000) a)01010101 b)11010101 c)00101011 d)10101011 Q2.The 2 s complement representation of (-539) 10 in hexadecimal is (GATE 2001) a)abe

### CS429: Computer Organization and Architecture

CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: September 18, 2017 at 12:48 CS429 Slideset 4: 1 Topics of this Slideset

### Floating Point Arithmetic

Floating Point Arithmetic Floating point numbers are frequently used in many applications. Implementation of arithmetic units such as adder, multiplier, etc for Floating point numbers are more complex

### On a 64-bit CPU. Size/Range vary by CPU model and Word size.

On a 64-bit CPU. Size/Range vary by CPU model and Word size. unsigned short x; //range 0 to 65553 signed short x; //range ± 32767 short x; //assumed signed There are (usually) no unsigned floats or doubles.

### C NUMERIC FORMATS. Overview. IEEE Single-Precision Floating-point Data Format. Figure C-0. Table C-0. Listing C-0.

C NUMERIC FORMATS Figure C-. Table C-. Listing C-. Overview The DSP supports the 32-bit single-precision floating-point data format defined in the IEEE Standard 754/854. In addition, the DSP supports an

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

### Floating-Point Arithmetic

Floating-Point Arithmetic if ((A + A) - A == A) { SelfDestruct() } Reading: Study Chapter 3. L12 Multiplication 1 Approximating Real Numbers on Computers Thus far, we ve entirely ignored one of the most