# CSCI 230 Class Notes Binary Number Representations and Arithmetic

Save this PDF as:

Size: px
Start display at page:

Download "CSCI 230 Class Notes Binary Number Representations and Arithmetic"

## Transcription

1 CSCI 230 Class otes Binary umber Representations and Arithmetic Mihran Tuceryan with some modifications by Snehasis Mukhopadhyay Jan 22, Decimal otation What does it mean when we write 495? How do we figure out what the value of the number is. In this example, the digit 5 is called the units digit, 9 is called the tens, and 4 is called the hundreds. To figure out what the value is we add This is what it means to write a number in decimal notation. Another way of saying it is there are units bunches, 9 ten unit bunches and 5 units. It is hard to see what s happening because the way we represent the numbers and the way we say the value of the number are embedded in the language. That is, in the English language, the way numbers are said (not all but most) is based on the decimal system. Another way to look at the above equation is: A number of points to note here: 10 is the base unit How much each digit contributes to the total value depends on its position in the notation. Definition: The idea of giving symbols different values that depend on where they are written and using 0 s to fill empty positions is called the positional-number system For base 10 (decimal) system, there are 10 symbols (digits) used: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Why? 1

2 & ( = & ( = 2 Binary System!" # %\$. Instead of using 10 as the base, we use 2. Symbols (digits) used: 0 and 1. The coefficients for each power of 2 in the positional representation is 0 or 1. Example: & ' )( +* To get the answer for this, we plug in the powers of 2 at each position and multiply by the coefficient. So, & ' )(, -\$/ \$23 -\$4 5, -\$/, 76 5, 8 -\$9 0 1 : & ;( This is conversion from binary to decimal system. 2.1 Conversion from decimal to binary Given a decimal value =, how do we find its binary representation? We start with the binary expansion of = as follows: > \$ > >/? \$4A \$/ where = is the decimal value of the binary number represented @. The problem converting from decimal to binary is to find the coefficients B for C, given the decimal value =. How do we do this? Looking at the expanded version of the binary number, we see that if we divide it by 2 and take the remainder, we would obtain. That is, \$ >2? KJ \$,ML quotient> >/? \$ remainder ow we repeat this division by 2 on the quotient after the first division and we get a remainder of, and so on. As we repeat this process, we get each one of the bits (digits of the binary number) in sequence from least significant bit (coefficient of \$ ) to the most significant bit (coefficient of \$ > ). Example: & ;( what in binary? We use repeated division by 2 and take the remainders: 2

3 quotient remainder which position \$ 13 / \$ 6 / \$ 3/2 1 1 \$. 1/2 0 1 So, putting the remainder bits in the correct positions, we obtain & ;( & ' )( G Another example: &POQ 6 O ( what in binary? We do the repeated division: quotient remainder bit position \$ 6786 / \$ 3393 / \$ 1696 / \$. 848 / \$2R 424 / \$/S 212 / \$/T 106 / \$ U 53 / \$/V 26 / \$/W 13 / \$ 6 / \$ X 3 / \$ 1 / So, putting the bits together in the correct positions, we get &POQ 6 O ( & ' F ' ( 2.2 Reasons for using binary numbers in a computer based system A computer based system is made up of electronic circuits. The components of these circuits (e.g, a transistor) carry two states, a low and a high charge. Manipulating the charges so that they can do something of use is what the computer does. The binary number system is well suited for this manipulation because it is a two state number system. It can be use as a model of the computer s circuit s with a 0 representing a low charge and a 1 as a high charge. By manipulating the circuits of the computer system to behave like the binary number system, the computer is able to perform calculations, the bases of all it s operation. Other number systems can be used, but the difficulty of creating more than two states makes them impractical. 3

4 3 Binary Arithmetic on Integers & & We define the basic operations: Addition: 1 ; 0 YZ ; [Z ; and \ 0 YZ We do the addition of binary numbers just like decimal numbers: add digit by digit, taking into account the carries. Example: ;( ( carries! decimal number first number second number sum Multiplication: Similar to long multiplication in decimal system. Example: & ; ;( & ( First number Second number First partial result Second partial result Third partial result Final sum Signed umber Representations & ;;( & ( For subtraction, we need a way to represent negative numbers (or signed numbers). There a a number of different representations. Below we give four of them. In all of the following, we assume that we have fixed the number of bits to represent numbers. This is because in most representations the sign bit tends to be placed in the leftmost bit location, and one has to know where the leftmost bit location is. 1. Signed magnitude representation: Simplest representation. The leftmost bit is the sign bit and the remaining bits are the magnitude represented as above Here bit 1 is the sign bit and bits 2 8 are the magnitude bits. Sign bit ] means a positive number and sign bit ^ means a negative number. Example: & O ( & +( &`_ ( ' ' \ ' ' 4

5 _ Problems are, treating the sign bit separately makes the hardware more complicated in order to take care of special conditions. Also in this representation we get two 0 s & ä ( &`_ ( \ on-unique representation for 0 s also complicates certain operations in hardware (e.g., comparison with 0) more complex. So this propery is not desirable. 2. Excess representation: For a given fixed number of bits, we remap the range such that roughly half the numbers are negative and half are positive. Here is an example of excess-8 notation for 4-bit numbers: _ _ \$ _ ; 6 Binary value notation excess-8 value _ O _bq So, here is where the term excess-8 notation comes from: binary value 6 excess-8 value. The leftmost bit in this case can also be used as the sign bit: sign bit ] means positive number and sign bit 5 means negative number. In a similar manner, excess-64 notation will use 7 bits and represent numbers between _ 64 to 63 both inclusive: excess-64 value binary value _co. 3. One s complement representation: egative numbers are represented by complementing all the bits in the binary representation of the magnitude. Complementing in binary means 5

6 d d d changing all the 1 s to 0 s and all the 0 s to ones. It is represented by the tilde (d ) character. b 1^ So d and d. Let s assume 8 bit long numbers. Example: & +( &`_ ( b ' F & b F ' )(ez ' Once more the leftmost bit can be regarded as the sign bit. Sign bit % means positive numbers and sign bit ^ means negative numbers. Disadvantage once more is the non-unique representation for Two s complement representation: This is represented by taking the one s complement representation and adding 1. Examples: & +( &f_ ( b F ' & ' ' ( 5 b^ b F 5 ] b ' Looking at 0 representation: & + ( &`_ ( & b ( 0 YZ 5 ] \ The leftmost bit in this case is dropped because it is the ninth bit. So we get _ 1 b Thus, we now have a unique representation for 0 in two s complement. Subtraction: The subtraction _ g is accomplished by adding the negative of the subtrahend. That is, to &f_bg ( perform the subtraction, we perform. This is easy to perform with two s complement notation. _hg &Pg ( 2 s complement 6

7 d O ; _ & Example: Compute QY_. ;1 ;( 2 s complement & b F )( 0 b & b ( 5 ] b ' QY_ ;, Q & ;( 2 s complement So, &iqy_ ;( & b ' ( _ ; sum overflow bit discarded 0 2 s complement. 4 Octal Representations Octal representations are base-8 representations which are sometimes used in computer science to present long binary (base-2) codes in a more compact (or, shorter) fashion. Basically, each octal digit (symbol) encodes three binary digits (bits). So conversion between octal and binary representations are quite straightforward. An n-digit octal number, @ is represented by the sum >2? 76 >/? >2? j6 76 We only need 8 digits for octal numbers: k 0, 1, 2, 3, 4, 5, 6, 7 l. The conversions back and forth between octal and decimal are done in exactly the same manner as between decimal and binary. To convert from octal to decimal, we evaluate the above sum. To convert from decimal to octal, we perform repeated divisions by 8, and take the remainders as the digits of the octal number. Example: Convert the decimal number 94 to octal. To do this we perform repeated divisions by 8: Therefore, & 4( number operation quotient remainder octal digit /mn omn ; \mn Z 0 stop stop stop stop & ; O ( V. We can check this by plugging the octal digits into the sum:, 76 p; 76 O j6 O p\$/ O One special property of number representations whose base is a power of 2 (such as octal) is that the conversion between this and base 2 (i.e., binary is as simple as writing the binary representations of 7

8 V each digit is and just inserting them in place of the digit; or grouping bits in the binary representation and replacing them with the equivalent digit. So, for octal numbers, since 6,D\$., we work in groups of 3 bits. We can write the binary representation for each octal digit: octal binary So to convert octal 136 to binary, I substitute for each octal digit its equivalent in binary given in the table above. This gives me & ; O ( & ' q ' b ( T R O O & And if we evaluate this binary number we get: + -\$ 5, -\$ 5, -\$/. 5, -\$/ 0 1 -\$r 5 6 ḧ \$, /4( 5 Hexadecimal umbers Hexadecimal system is base-16 number representation system. An n-bit hexadecimal number, >/? >/? is represented by the sum >/? O >/? >/? O @ We need 16 digits to represent hexadecimal numbers: k 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F l. The conversions back and forth between octal and decimal are done in exactly the same manner as between decimal and binary or octal. To convert from hexadecimal to binary, we evaluate the above sum. To convert from decimal to hexadecimal, we perform repeated divisions by 16, and take the remainders as the digits of the hexadecimal number. Example: Convert decimal 94 to hexadecimal representation. To do this we perform repeated divisions by 16: Therefore, & 4( number operation quotient remainder hex digit /bm5 O s qm% O stop stop stop stop & s[( T. We can check this by plugging the hexadecimal digits into the sum: : O psm O t56 5 1% 8

9 Base 16 is a power of 2 just like the octal system is. Do the conversion between hex and binary by grouping bits (of four in this case) applies equally. We write the binary equivalents for each of the hex digits: hexadecimal binary A 1010 B 1011 C 1100 D 1101 E 1110 F 1111 So, to convert hexadecimal 5E to binary, we substitute the binary codes for each of the hex digits: & /s!( & T ' ' ( T R. O O & Which when evaluated will yield + -\$ 5, -\$ 5, -\$ 5, -\$ 0 1 -\$ 5 6 ḧ \$, /4( 6 Fractional Representations in Binary The fractional numbers in binary are represented just like in the decimal system that we are used to: with a fractional point indicating where the base to the power of 0 ends. So in decimal system when we write the number 456.5, we mean u A O? The fractional point in separates the from the negative powers of 10. The binary fractional representation works in the same way, except we have a base of 2 instead of 10. So, when we write the binary fraction , we mean, 7\$2v j\$4w 0, 7\$/3 5, 7\$? 5, -\$? 9

10 6.1 Conversions Going from binary to decimal is similar to evaluating the integer representations. For a binary number with n bits for the integer part and m bits for the fractional part, we evaluate the sum: >/? -\$ >2? A >/? -\$/ @ '?4x 7\$?4x Converting from decimal to binary works as follows: 1. The integer part is converted just like before: with repeated division by 2 and taking the remainders in the order from LSB to MSB. 2. The fractional part is converted after a reasoning similar to how we derived the conversion of the integer part. A fractional part with m bits, @ '?4x, is represented by the following sum: '? 7\$? A '?4x -\$?4x ow, if we multiply this by 2, we get the sum: '? '?4x 7\$?4x3y which means that the '? is the coefficient of \$ we get after the multiplication. ow, we can multiply the fractional part of the result by two and get '?, and so on, until we get all the bits. Example: Convert the decimal number to binary fractional representation. Here s how it works. We first convert the integer part, 5, to binary. I will not go over this in detail, but we perform repeated divisions by 2 on 5 and get the string 101 for its binary representation from the remainders of each division. We are now left with the fractional part to convert. We start by multiplying by two and get the resulting whole part of each multiplication result. Here s how it works. fraction operation result binary bit \$ j O \$ '? Z \$ 7 \$ '? 5 \$ '?. Z 0.0 stop stop stop So, the resulting binary representation of & O \$( is & ' (. Putting this together with the integer part we get, & O \$( & ' F )(. 7 Machine representation of floating point numbers We saw above how to represent integers and binary fractions in the machine. The floating point representation is another way to represent real numbers in the hardware in a fixed number of bits. 10

11 Since we have a fixed number of bits (usually 32 bits for single precision and 64 bits for double precision, although this can vary from machine to machine), we would like to have a presentation which can represent a wide range of the real numbers. Once more, notice that for any fixed precision representation, we will only have a fixed number of possible bit combinations. For example, for 32 bits, we have \$.X possible combinations of 0 s and 1 s. So the question becomes what we do with these \$.X possibilities. Basically, we will regard each of these possible combinations of binary bits as samples from the real line. There are a number of different floating point formats in the industry. Different vendors may have different formats for representing floating point numbers. For the purposes of this discussion, we will use the IBM System/370 floating point format. The IEEE standard floating point format is similar to this with some differences which we will mention later. The 32 bit single precision floating point format for IBM 370 is as follows: sign exponent mantissa 1 bit 7 bits 24 bits We need to pick a radix with which we can interpret the bit pattern given above as a real number. The IBM format uses radix 16. Here the exponent is excess-64 notation. The number in the exponent field will represent the radix (16 in this case) raised to this number. The sign bit of the number (leftmost bit) is 0 if the number is positive and 1 if it is negative. The mantissa is a normalized fractional representation using the radix as the base. ormalized mantissa means that the digit after the fractional point is non-zero and if needed the mantissa should be shifted appropriately to make this digit non-zero and the exponent adjusted appropriately. Example: What is the value of the following floating point number? First, this number is negative because its sign bit is 1. The exponent ( ) has a binary value of 66. But since the exponent is in excess-64 notation, it is representing the value 2. ow, we compute the value of the mantissa. The mantissa is which in hexadecimal is 93D7C2. This is the normalized fractional representation and the implicit fractional point is right before the digit 9. Putting all of this together, the value of the above floating point number is: _[& O? A ; O? pz{ O?. Q O? R p } O? S \$ O? T (t O _[& O? A ; O? 5 ; O?. Q O? R 5 \$ : O? S \$ O? T (t O _[& O w ; : O 5 ; O? A Q O? 5 \$ O?. \$! O? R ( _[& p; p 6' )\$ q p \$ Q ;/; Q q \$ \$ O 6 Q p ; F Q Q 6' )\$ ( _ Q 6 4\$/6 ; Q 6' \$ Example: What is the value of the following floating point number?

12 Once again, the sign bit is 1, so the number is negative. The exponent ( ) has a binary value of 62. In excess-64 notation this corresponds to an integer value of -2. So the exponent is -2. ow we compute the mantissa just like the first example above. The mantissa in hex notation is CA4DAB, with the implicit fractional point being at the left before the C. Putting all this together, we get _[& ~ O? Z O? 3ḧ O?. pz O? R ḧz O? S O? T (t O? _[& \$ O? 5 O? 3ḧ O?. 5 ; O? R 5 O? S 0, O? T (9 : O? _[& \$ O S 5 O R ḧ O. 5 ; O 5 O 0 + O (t O? V _[& \$ 6 Q/O 5 O ; O j O 5 ; -\$ O 5 O 0 )(t O? V _[& \$ 6\$ F )\$q O ; O q 0 O ;6/ ;;\$ 69 0 O 9 0 )(t O? V _ ;\$ 6' )! : O? V ; 6 O Q O \$/;' Definition: The number of place values used to represent a number is called the precision. Most single precision floating point numbers are represented by 32 bits although this may vary from specific machine to machine. Double precision floating point numbers use 64 bits to store the value. The organization is given below. For 32 bit numbers we have: sign exponent mantissa 1 bit 7 bits 24 bits And for 64 bit double precision numbers we have: sign exponent mantissa 1 bit 7 bits 56 bits The special string of all 0 s represents the value of 0 in the IBM 370 format. ow we can answer the following questions: What is the largest single precision number we can represent? This can be derived from the bit pattern in the 32 bit representation. The exponent is allocated 7 bits and for the largest value it has to have all the bits set to 1. The mantissa also has to have all the hexadecimal digits set to F, and the sign field has to be 0. So, we get the following bit pattern: The exponent in excess-64 representation represents the value of +63. The value of the total number then is: &P O? O? : O?. O? R O? S O? T (t O y T. ƒ, O y T. ƒ y U T 12

13 What is the most negative single precision number we can represent? The bit pattern for the mantissa and exponent would be similar to the largest positive single precision number given above (i.e., the absolute values should be the maximum in both cases). The sign bit would be negative in this case. So, the bit pattern would be Which going through a similar analysis as above would result in this number being approximately _ y U T. What is the smallest positive single precision number we can represent? The bit pattern in this case would be The first hexadecimal digit in the mantissa in this case is non-zero because of normalization and the smallest non-zero hex digit is 1. The exponent is the most negative it can be (-64 in excess-64 notation in this case). So putting all these together we get the value of the number to be &, O? f(9 : O? T R ] O? T S ƒ? U V What is the least negative single precision number? This is similar to the smallest positive number, only the sign is negative. So the bit pattern in this case looks like: and its value is approximately _? U V The IEEE floating point standard 754 is similar to the IBM 370 format. Here is the IEEE format for 32 bit single precision numbers: sign exponent mantissa 1 bit 8 bits 23 bits And for 64 bit double precision numbers we have: sign exponent mantissa 1 bit 11 bits 52 bits The radix in IEEE format is 2. Let s look at the single precision, 32-bit case. The IEEE standard defines special values for some of the special strings of bits which are given in the following table ( " is the sign bit): 13

14 ( ( Exponent, # Mantissa, Value % 255 a (not-a-number) &`_ )(ˆ ˆ Š # Š \$ &`_ )(ˆ ˆ\$/Œ? U & % &f_ ( \$? T & 0 &`_ )(ˆ ` 0 0 For the values of the exponent in the range 1 to 254 (the values 0 and 255 are treated as special cases as is seen in the table above), the exponent is in excess notation with a range of _ \$ O through 127. In this case, the mantissa is interpreted as a normalized number in which the bit immediately to the left of the fractional point is implied (i.e., it is not explicitely represented). Therefore, the mantissa is effectively 24 bits even though physically there are 23 bits allocated. 14

### Computer Science 281 Binary and Hexadecimal Review

Computer Science 281 Binary and Hexadecimal Review 1 The Binary Number System Computers store everything, both instructions and data, by using many, many transistors, each of which can be in one of two

### The string of digits 101101 in the binary number system represents the quantity

Data Representation Section 3.1 Data Types Registers contain either data or control information Control information is a bit or group of bits used to specify the sequence of command signals needed for

### Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

ECE Department Summer LECTURE #5: Number Systems EEL : Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz Decimal Number System: -Our standard number system is base, also

### CSI 333 Lecture 1 Number Systems

CSI 333 Lecture 1 Number Systems 1 1 / 23 Basics of Number Systems Ref: Appendix C of Deitel & Deitel. Weighted Positional Notation: 192 = 2 10 0 + 9 10 1 + 1 10 2 General: Digit sequence : d n 1 d n 2...

### Binary Numbers. Bob Brown Information Technology Department Southern Polytechnic State University

Binary Numbers Bob Brown Information Technology Department Southern Polytechnic State University Positional Number Systems The idea of number is a mathematical abstraction. To use numbers, we must represent

### Lecture 11: Number Systems

Lecture 11: Number Systems Numeric Data Fixed point Integers (12, 345, 20567 etc) Real fractions (23.45, 23., 0.145 etc.) Floating point such as 23. 45 e 12 Basically an exponent representation Any number

### Number Representation

Number Representation CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Topics to be Discussed How are numeric data

### LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

LSN 2 Number Systems Department of Engineering Technology LSN 2 Decimal Number System Decimal number system has 10 digits (0-9) Base 10 weighting system... 10 5 10 4 10 3 10 2 10 1 10 0. 10-1 10-2 10-3

### Binary Number System. 16. Binary Numbers. Base 10 digits: 0 1 2 3 4 5 6 7 8 9. Base 2 digits: 0 1

Binary Number System 1 Base 10 digits: 0 1 2 3 4 5 6 7 8 9 Base 2 digits: 0 1 Recall that in base 10, the digits of a number are just coefficients of powers of the base (10): 417 = 4 * 10 2 + 1 * 10 1

### Solution for Homework 2

Solution for Homework 2 Problem 1 a. What is the minimum number of bits that are required to uniquely represent the characters of English alphabet? (Consider upper case characters alone) The number of

### Systems I: Computer Organization and Architecture

Systems I: Computer Organization and Architecture Lecture 2: Number Systems and Arithmetic Number Systems - Base The number system that we use is base : 734 = + 7 + 3 + 4 = x + 7x + 3x + 4x = x 3 + 7x

### 198:211 Computer Architecture

198:211 Computer Architecture Topics: Lecture 8 (W5) Fall 2012 Data representation 2.1 and 2.2 of the book Floating point 2.4 of the book 1 Computer Architecture What do computers do? Manipulate stored

### CPEN 214 - Digital Logic Design Binary Systems

CPEN 4 - Digital Logic Design Binary Systems C. Gerousis Digital Design 3 rd Ed., Mano Prentice Hall Digital vs. Analog An analog system has continuous range of values A mercury thermometer Vinyl records

### Section 1.4 Place Value Systems of Numeration in Other Bases

Section.4 Place Value Systems of Numeration in Other Bases Other Bases The Hindu-Arabic system that is used in most of the world today is a positional value system with a base of ten. The simplest reason

### Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

Binary Representation The basis of all digital data is binary representation. Binary - means two 1, 0 True, False Hot, Cold On, Off We must be able to handle more than just values for real world problems

### Number Systems and Radix Conversion

Number Systems and Radix Conversion Sanjay Rajopadhye, Colorado State University 1 Introduction These notes for CS 270 describe polynomial number systems. The material is not in the textbook, but will

### 1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

Exercises 1 - number representations Questions 1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal: (a) 3012 (b) - 435 2. For each of

### Number Conversions Dr. Sarita Agarwal (Acharya Narendra Dev College,University of Delhi)

Conversions Dr. Sarita Agarwal (Acharya Narendra Dev College,University of Delhi) INTRODUCTION System- A number system defines a set of values to represent quantity. We talk about the number of people

### Useful Number Systems

Useful Number Systems Decimal Base = 10 Digit Set = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} Binary Base = 2 Digit Set = {0, 1} Octal Base = 8 = 2 3 Digit Set = {0, 1, 2, 3, 4, 5, 6, 7} Hexadecimal Base = 16 = 2

### Lecture 2. Binary and Hexadecimal Numbers

Lecture 2 Binary and Hexadecimal Numbers Purpose: Review binary and hexadecimal number representations Convert directly from one base to another base Review addition and subtraction in binary representations

### CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

CDA 3200 Digital Systems Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012 Outline Data Representation Binary Codes Why 6-3-1-1 and Excess-3? Data Representation (1/2) Each numbering

### Levent EREN levent.eren@ieu.edu.tr A-306 Office Phone:488-9882 INTRODUCTION TO DIGITAL LOGIC

Levent EREN levent.eren@ieu.edu.tr A-306 Office Phone:488-9882 1 Number Systems Representation Positive radix, positional number systems A number with radix r is represented by a string of digits: A n

### Signed Binary Arithmetic

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

### 2011, The McGraw-Hill Companies, Inc. Chapter 3

Chapter 3 3.1 Decimal System The radix or base of a number system determines the total number of different symbols or digits used by that system. The decimal system has a base of 10 with the digits 0 through

### Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

Divide: Paper & Pencil Computer Architecture ALU Design : Division and Floating Point 1001 Quotient Divisor 1000 1001010 Dividend 1000 10 101 1010 1000 10 (or Modulo result) See how big a number can be

### Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

Decimal Division Remember 4th grade long division? 43 // quotient 12 521 // divisor dividend -480 41-36 5 // remainder Shift divisor left (multiply by 10) until MSB lines up with dividend s Repeat until

### HOMEWORK # 2 SOLUTIO

HOMEWORK # 2 SOLUTIO Problem 1 (2 points) a. There are 313 characters in the Tamil language. If every character is to be encoded into a unique bit pattern, what is the minimum number of bits required to

### Fractional Numbers. Fractional Number Notations. Fixed-point Notation. Fixed-point Notation

2 Fractional Numbers Fractional Number Notations 2010 - Claudio Fornaro Ver. 1.4 Fractional numbers have the form: xxxxxxxxx.yyyyyyyyy where the x es constitute the integer part of the value and the y

### NUMBER SYSTEMS. William Stallings

NUMBER SYSTEMS William Stallings The Decimal System... The Binary System...3 Converting between Binary and Decimal...3 Integers...4 Fractions...5 Hexadecimal Notation...6 This document available at WilliamStallings.com/StudentSupport.html

### NUMBER SYSTEMS. 1.1 Introduction

NUMBER SYSTEMS 1.1 Introduction There are several number systems which we normally use, such as decimal, binary, octal, hexadecimal, etc. Amongst them we are most familiar with the decimal number system.

### EE 261 Introduction to Logic Circuits. Module #2 Number Systems

EE 261 Introduction to Logic Circuits Module #2 Number Systems Topics A. Number System Formation B. Base Conversions C. Binary Arithmetic D. Signed Numbers E. Signed Arithmetic F. Binary Codes Textbook

### Base Conversion written by Cathy Saxton

Base Conversion written by Cathy Saxton 1. Base 10 In base 10, the digits, from right to left, specify the 1 s, 10 s, 100 s, 1000 s, etc. These are powers of 10 (10 x ): 10 0 = 1, 10 1 = 10, 10 2 = 100,

### Unsigned Conversions from Decimal or to Decimal and other Number Systems

Page 1 of 5 Unsigned Conversions from Decimal or to Decimal and other Number Systems In all digital design, analysis, troubleshooting, and repair you will be working with binary numbers (or base 2). It

### Binary Numbers. Binary Octal Hexadecimal

Binary Numbers Binary Octal Hexadecimal Binary Numbers COUNTING SYSTEMS UNLIMITED... Since you have been using the 10 different digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 all your life, you may wonder how

### CS321. Introduction to Numerical Methods

CS3 Introduction to Numerical Methods Lecture Number Representations and Errors Professor Jun Zhang Department of Computer Science University of Kentucky Lexington, KY 40506-0633 August 7, 05 Number in

### Binary math. Resources and methods for learning about these subjects (list a few here, in preparation for your research):

Binary math This worksheet and all related files are licensed under the Creative Commons Attribution License, version 1.0. To view a copy of this license, visit http://creativecommons.org/licenses/by/1.0/,

### 2 Number Systems 2.1. Foundations of Computer Science Cengage Learning

2 Number Systems 2.1 Foundations of Computer Science Cengage Learning 2.2 Objectives After studying this chapter, the student should be able to: Understand the concept of number systems. Distinguish between

### ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

ECE 0142 Computer Organization Lecture 3 Floating Point Representations 1 Floating-point arithmetic We often incur floating-point programming. Floating point greatly simplifies working with large (e.g.,

### 2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal

2/9/9 Binary number system Computer (electronic) systems prefer binary numbers Binary number: represent a number in base-2 Binary numbers 2 3 + 7 + 5 Some terminology Bit: a binary digit ( or ) Hexadecimal

### CHAPTER 5 Round-off errors

CHAPTER 5 Round-off errors In the two previous chapters we have seen how numbers can be represented in the binary numeral system and how this is the basis for representing numbers in computers. Since any

### Chapter 1: Digital Systems and Binary Numbers

Chapter 1: Digital Systems and Binary Numbers Digital age and information age Digital computers general purposes many scientific, industrial and commercial applications Digital systems telephone switching

### To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

Binary Numbers In computer science we deal almost exclusively with binary numbers. it will be very helpful to memorize some binary constants and their decimal and English equivalents. By English equivalents

### Binary, Hexadecimal, Octal, and BCD Numbers

23CH_PHCalter_TMSETE_949118 23/2/2007 1:37 PM Page 1 Binary, Hexadecimal, Octal, and BCD Numbers OBJECTIVES When you have completed this chapter, you should be able to: Convert between binary and decimal

### 4 Operations On Data

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

### 6 3 4 9 = 6 10 + 3 10 + 4 10 + 9 10

Lesson The Binary Number System. Why Binary? The number system that you are familiar with, that you use every day, is the decimal number system, also commonly referred to as the base- system. When you

### CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011

CS101 Lecture 11: Number Systems and Binary Numbers Aaron Stevens 14 February 2011 1 2 1 3!!! MATH WARNING!!! TODAY S LECTURE CONTAINS TRACE AMOUNTS OF ARITHMETIC AND ALGEBRA PLEASE BE ADVISED THAT CALCULTORS

### Goals. Unary Numbers. Decimal Numbers. 3,148 is. 1000 s 100 s 10 s 1 s. Number Bases 1/12/2009. COMP370 Intro to Computer Architecture 1

Number Bases //9 Goals Numbers Understand binary and hexadecimal numbers Be able to convert between number bases Understand binary fractions COMP37 Introduction to Computer Architecture Unary Numbers Decimal

### quotient = dividend / divisor, with a remainder Given dividend and divisor, we want to obtain quotient (Q) and remainder (R)

Binary division quotient = dividend / divisor, with a remainder dividend = divisor quotient + remainder Given dividend and divisor, we want to obtain quotient (Q) and remainder (R) We will start from our

### The Essentials of Computer Organization and Architecture. Linda Null and Julia Lobur Jones and Bartlett Publishers, 2003

The Essentials of Computer Organization and Architecture Linda Null and Julia Lobur Jones and Bartlett Publishers, 2003 Chapter 2 Instructor's Manual Chapter Objectives Chapter 2, Data Representation,

### 2 Number Systems. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

2 Number Systems 2.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Understand the concept of number systems. Distinguish

### Digital Design. Assoc. Prof. Dr. Berna Örs Yalçın

Digital Design Assoc. Prof. Dr. Berna Örs Yalçın Istanbul Technical University Faculty of Electrical and Electronics Engineering Office Number: 2318 E-mail: siddika.ors@itu.edu.tr Grading 1st Midterm -

### This 3-digit ASCII string could also be calculated as n = (Data[2]-0x30) +10*((Data[1]-0x30)+10*(Data[0]-0x30));

Introduction to Embedded Microcomputer Systems Lecture 5.1 2.9. Conversions ASCII to binary n = 100*(Data[0]-0x30) + 10*(Data[1]-0x30) + (Data[2]-0x30); This 3-digit ASCII string could also be calculated

### Positional Numbering System

APPENDIX B Positional Numbering System A positional numbering system uses a set of symbols. The value that each symbol represents, however, depends on its face value and its place value, the value associated

### 3. Convert a number from one number system to another

3. Convert a number from one number system to another Conversion between number bases: Hexa (16) Decimal (10) Binary (2) Octal (8) More Interest Way we need conversion? We need decimal system for real

### CHAPTER 3 Numbers and Numeral Systems

CHAPTER 3 Numbers and Numeral Systems Numbers play an important role in almost all areas of mathematics, not least in calculus. Virtually all calculus books contain a thorough description of the natural,

### Numbering Systems. InThisAppendix...

G InThisAppendix... Introduction Binary Numbering System Hexadecimal Numbering System Octal Numbering System Binary Coded Decimal (BCD) Numbering System Real (Floating Point) Numbering System BCD/Binary/Decimal/Hex/Octal

### Data Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:

Chapter 3 Data Storage Objectives After studying this chapter, students should be able to: List five different data types used in a computer. Describe how integers are stored in a computer. Describe how

### Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

Today Binary addition Representing negative numbers 2 Binary Addition Consider the following binary numbers: 0 0 1 0 0 1 1 0 0 0 1 0 1 0 1 1 How do we add these numbers? 3 Binary Addition 0 0 1 0 0 1 1

### Binary Representation

Binary Representation The basis of all digital data is binary representation. Binary - means two 1, 0 True, False Hot, Cold On, Off We must tbe able to handle more than just values for real world problems

### CS 16: Assembly Language Programming for the IBM PC and Compatibles

CS 16: Assembly Language Programming for the IBM PC and Compatibles First, a little about you Your name Have you ever worked with/used/played with assembly language? If so, talk about it Why are you taking

### This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers

This Unit: Floating Point Arithmetic CIS 371 Computer Organization and Design Unit 7: Floating Point App App App System software Mem CPU I/O Formats Precision and range IEEE 754 standard Operations Addition

### plc numbers - 13.1 Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

plc numbers - 3. Topics: Number bases; binary, octal, decimal, hexadecimal Binary calculations; s compliments, addition, subtraction and Boolean operations Encoded values; BCD and ASCII Error detection;

### The BBP Algorithm for Pi

The BBP Algorithm for Pi David H. Bailey September 17, 2006 1. Introduction The Bailey-Borwein-Plouffe (BBP) algorithm for π is based on the BBP formula for π, which was discovered in 1995 and published

### Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 04 Digital Logic II May, I before starting the today s lecture

### = Chapter 1. The Binary Number System. 1.1 Why Binary?

Chapter The Binary Number System. Why Binary? The number system that you are familiar with, that you use every day, is the decimal number system, also commonly referred to as the base-0 system. When you

### Decimal Numbers: Base 10 Integer Numbers & Arithmetic

Decimal Numbers: Base 10 Integer Numbers & Arithmetic Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 )+(1x10 0 ) Ward 1 Ward 2 Numbers: positional notation Number

### Fixed-Point Arithmetic

Fixed-Point Arithmetic Fixed-Point Notation A K-bit fixed-point number can be interpreted as either: an integer (i.e., 20645) a fractional number (i.e., 0.75) 2 1 Integer Fixed-Point Representation N-bit

### Binary Numbering Systems

Binary Numbering Systems April 1997, ver. 1 Application Note 83 Introduction Binary numbering systems are used in virtually all digital systems, including digital signal processing (DSP), networking, and

### Data Storage 3.1. Foundations of Computer Science Cengage Learning

3 Data Storage 3.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List five different data types used in a computer. Describe how

### DIGITAL FUNDAMENTALS lesson 4 Number systems

The decimal number system In the decimal number system the base is 0. For example the number 4069 means 4x000 + 0x00 + 6x0 + 9x. The powers of 0 with the number 4069 in tabelvorm are: power 0 3 0 2 0 0

### Chapter 7 Lab - Decimal, Binary, Octal, Hexadecimal Numbering Systems

Chapter 7 Lab - Decimal, Binary, Octal, Hexadecimal Numbering Systems This assignment is designed to familiarize you with different numbering systems, specifically: binary, octal, hexadecimal (and decimal)

### ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-470/570: Microprocessor-Based System Design Fall 2014.

REVIEW OF NUMBER SYSTEMS Notes Unit 2 BINARY NUMBER SYSTEM In the decimal system, a decimal digit can take values from to 9. For the binary system, the counterpart of the decimal digit is the binary digit,

### Number Systems, Base Conversions, and Computer Data Representation

, Base Conversions, and Computer Data Representation Decimal and Binary Numbers When we write decimal (base 10) numbers, we use a positional notation system. Each digit is multiplied by an appropriate

### Simulation & Synthesis Using VHDL

Floating Point Multipliers: Simulation & Synthesis Using VHDL By: Raj Kumar Singh - B.E. (Hons.) Electrical & Electronics Shivananda Reddy - B.E. (Hons.) Electrical & Electronics BITS, PILANI Outline Introduction

### CHAPTER TWO. 2.1 Unsigned Binary Counting. Numbering Systems

CHAPTER TWO Numbering Systems Chapter one discussed how computers remember numbers using transistors, tiny devices that act like switches with only two positions, on or off. A single transistor, therefore,

### Restoring division. 2. Run the algorithm Let s do 0111/0010 (7/2) unsigned. 3. Find remainder here. 4. Find quotient here.

Binary division Dividend = divisor q quotient + remainder CS/COE447: Computer Organization and Assembly Language Given dividend and divisor, we want to obtain quotient (Q) and remainder (R) Chapter 3 We

### Chapter 2. Binary Values and Number Systems

Chapter 2 Binary Values and Number Systems Numbers Natural numbers, a.k.a. positive integers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645, 32 Negative numbers A

### Number Systems I. CIS008-2 Logic and Foundations of Mathematics. David Goodwin. 11:00, Tuesday 18 th October

Number Systems I CIS008-2 Logic and Foundations of Mathematics David Goodwin david.goodwin@perisic.com 11:00, Tuesday 18 th October 2011 Outline 1 Number systems Numbers Natural numbers Integers Rational

### Negative Integer Exponents

7.7 Negative Integer Exponents 7.7 OBJECTIVES. Define the zero exponent 2. Use the definition of a negative exponent to simplify an expression 3. Use the properties of exponents to simplify expressions

### MATH-0910 Review Concepts (Haugen)

Unit 1 Whole Numbers and Fractions MATH-0910 Review Concepts (Haugen) Exam 1 Sections 1.5, 1.6, 1.7, 1.8, 2.1, 2.2, 2.3, 2.4, and 2.5 Dividing Whole Numbers Equivalent ways of expressing division: a b,

### Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:

Numeral Systems Which number is larger? 25 8 We need to distinguish between numbers and the symbols that represent them, called numerals. The number 25 is larger than 8, but the numeral 8 above is larger

### Lecture 8: Binary Multiplication & Division

Lecture 8: Binary Multiplication & Division Today s topics: Addition/Subtraction Multiplication Division Reminder: get started early on assignment 3 1 2 s Complement Signed Numbers two = 0 ten 0001 two

### 1.3 Order of Operations

1.3 Order of Operations As it turns out, there are more than just 4 basic operations. There are five. The fifth basic operation is that of repeated multiplication. We call these exponents. There is a bit

### Data Representation. Data Representation, Storage, and Retrieval. Data Representation. Data Representation. Data Representation. Data Representation

, Storage, and Retrieval ULM/HHIM Summer Program Project 3, Day 3, Part 3 Digital computers convert the data they process into a digital value. Text Audio Images/Graphics Video Digitizing 00000000... 6/8/20

### Measures of Error: for exact x and approximation x Absolute error e = x x. Relative error r = (x x )/x.

ERRORS and COMPUTER ARITHMETIC Types of Error in Numerical Calculations Initial Data Errors: from experiment, modeling, computer representation; problem dependent but need to know at beginning of calculation.

### COMPSCI 210. Binary Fractions. Agenda & Reading

COMPSCI 21 Binary Fractions Agenda & Reading Topics: Fractions Binary Octal Hexadecimal Binary -> Octal, Hex Octal -> Binary, Hex Decimal -> Octal, Hex Hex -> Binary, Octal Animation: BinFrac.htm Example

### Binary Numbers The Computer Number System

Binary Numbers The Computer Number System Number systems are simply ways to count things. Ours is the base-0 or radix-0 system. Note that there is no symbol for 0 or for the base of any system. We count,2,3,4,5,6,7,8,9,

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

### Number and codes in digital systems

Number and codes in digital systems Decimal Numbers You are familiar with the decimal number system because you use them everyday. But their weighted structure is not understood. In the decimal number

### Session 29 Scientific Notation and Laws of Exponents. If you have ever taken a Chemistry class, you may have encountered the following numbers:

Session 9 Scientific Notation and Laws of Exponents If you have ever taken a Chemistry class, you may have encountered the following numbers: There are approximately 60,4,79,00,000,000,000,000 molecules

### Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer

Computers CMPT 125: Lecture 1: Understanding the Computer Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University January 3, 2009 A computer performs 2 basic functions: 1.

### 2.6 Exponents and Order of Operations

2.6 Exponents and Order of Operations We begin this section with exponents applied to negative numbers. The idea of applying an exponent to a negative number is identical to that of a positive number (repeated

### Chapter 1. Binary, octal and hexadecimal numbers

Chapter 1. Binary, octal and hexadecimal numbers This material is covered in the books: Nelson Magor Cooke et al, Basic mathematics for electronics (7th edition), Glencoe, Lake Forest, Ill., 1992. [Hamilton

### > 2. Error and Computer Arithmetic

> 2. Error and Computer Arithmetic Numerical analysis is concerned with how to solve a problem numerically, i.e., how to develop a sequence of numerical calculations to get a satisfactory answer. Part

### Fractions and Decimals

Fractions and Decimals Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles December 1, 2005 1 Introduction If you divide 1 by 81, you will find that 1/81 =.012345679012345679... The first

### Chapter 7 - Roots, Radicals, and Complex Numbers

Math 233 - Spring 2009 Chapter 7 - Roots, Radicals, and Complex Numbers 7.1 Roots and Radicals 7.1.1 Notation and Terminology In the expression x the is called the radical sign. The expression under the

### The University of Nottingham

The University of Nottingham School of Computer Science A Level 1 Module, Autumn Semester 2007-2008 Computer Systems Architecture (G51CSA) Time Allowed: TWO Hours Candidates must NOT start writing their

### Integer multiplication

Integer multiplication Suppose we have two unsigned integers, A and B, and we wish to compute their product. Let A be the multiplicand and B the multiplier: A n 1... A 1 A 0 multiplicand B n 1... B 1 B