# CHAPTER 2 Data Representation in Computer Systems

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 CHAPTER 2 Data Representation in Computer Systems 2.1 Introduction Positional Numbering Systems Converting Between Bases Converting Unsigned Whole Numbers Converting Fractions Converting between Power-of-Two Radices Signed Integer Representation Signed Magnitude Complement Systems Unsigned Versus Signed Numbers Computers, Arithmetic, and Booth s Algorithm Carry Versus Overflow Binary Multiplication and Division Using Shifting Floating-Point Representation A Simple Model Floating-Point Arithmetic Floating-Point Errors The IEEE-754 Floating-Point Standard Range, Precision, and Accuracy Additional Problems with Floating-Point Numbers Character Codes Binary-Coded Decimal EBCDIC ASCII Unicode Error Detection and Correction Cyclic Redundancy Check Hamming Codes Reed-Soloman 102 Chapter Summary 103 CMPS375 Class Notes (Chap02) Page 1 / 20 by Kuo-pao Yang

2 2.1 Introduction 47 This chapter describes the various ways in which computers can store and manipulate numbers and characters. Bit: The most basic unit of information in a digital computer is called a bit, which is a contraction of binary digit. Byte: In 1964, the designers of the IBM System/360 main frame computer established a convention of using groups of 8 bits as the basic unit of addressable computer storage. They called this collection of 8 bits a byte. Word: Computer words consist of two or more adjacent bytes that are sometimes addressed and almost always are manipulated collectively. The word size represents the data size that is handled most efficiently by a particular architecture. Words can be 16 bits, 32 bits, 64 bits. Nibbles: Eight-bit bytes can be divided into two 4-bit halves call nibbles. 2.2 Positional Numbering Systems 48 Radix (or Base): The general idea behind positional numbering systems is that a numeric value is represented through increasing powers of a radix (or base). System Radix Allowable Digits Decimal 10 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Binary 2 0, 1 Octal 8 0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal 16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F TABLE 2.1 Some Number to Remember EXAMPLE 2.1 Three numbers represented as powers of a radix = 2 * * * * * = 2 * * * 3 0 = CMPS375 Class Notes (Chap02) Page 2 / 20 by Kuo-pao Yang

3 = 1 * * * * * 2 0 = Converting Between Bases 48 There are two important groups of number base conversions: 1. Conversion of decimal numbers to base-r numbers 2. Conversion of base-r numbers to decimal numbers Converting Unsigned Whole Numbers 49 EXAMPLE 2.3 Convert to base 3 using the division-remainder method = EXAMPLE 2.4 Convert to binary = A binary number with N bits can represent unsigned integer from 0 to 2 n 1. Overflow: the result of an arithmetic operation is outside the range of allowable precision for the give number of bits. CMPS375 Class Notes (Chap02) Page 3 / 20 by Kuo-pao Yang

4 2.3.2 Converting Fractions 51 EXAMPLE 2.6 Convert to base = EXAMPLE 2.7 Convert to binary with 4 bits to the right of the binary point. Reading from top to bottom, = to four binary places. We simply discard (or truncate) our answer when the desired accuracy has been achieved = X X X X EXAMPLE 2.8 Convert to base 3 First, convert to decimal = Then convert to base = We have = Converting between Power-of-Two Radices 54 EXAMPLE 2.9 Convert to octal and hexadecimal = Separate into groups of 3 for octal conversion = C9D 16 Separate into groups of 4 for octal conversion CMPS375 Class Notes (Chap02) Page 4 / 20 by Kuo-pao Yang

5 2.4 Signed Integer Representation 54 By convention, a 1 in the high-order bit indicate a negative number Signed Magnitude 54 A signed-magnitude number has a sign as its left-most bit (also referred to as the high-order bit or the most significant bit) while the remaining bits represent the magnitude (or absolute value) of the numeric value. N bits can represent (2 n-1-1) to 2 n-1-1 EXAMPLE 2.10 Add to using signed-magnitude arithmetic (79) (35) = (114) There is no overflow in this example EXAMPLE 2.11 Add to using signed-magnitude arithmetic. An overflow condition and the carry is discarded, resulting in an incorrect sum. We obtain the erroneous result of (79) (99) = (50) EXAMPLE 2.12 Subtract from using signed-magnitude arithmetic. We find (99) (79) = (20) in signed-magnitude representation. EXAMPLE 2.14 EXAMPLE 2.15 The signed magnitude has two representations for zero, and (and mathematically speaking, the simple shouldn t happen!) Complement Systems 60 One s Complement o This sort of bit-flipping is very simple to implement in computer hardware. o EXAMPLE 2.16 Express 2310 and -910 in 8-bit binary one s complement form = + ( ) = = - ( ) = o EXAMPLE 2.17 o EXAMPLE 2.18 The primary disadvantage of one s complement is that we still have two representations for zero: and CMPS375 Class Notes (Chap02) Page 5 / 20 by Kuo-pao Yang

6 Two s Complement o Find the one s complement and add 1. o EXAMPLE 2.19 Express 23 10, , and in 8-bit binary two s complement form = + ( ) = = - ( ) = = = - ( ) = = o EXAMPLE 2.20 Add 9 10 to using two s complement arithmetic (9 10 ) ( ) = ( ) <= Carries ( 9) (-23) (-14) o EXAMPLE 2.21 Find the sum of and in binary using two s complement arithmetic (23 10 ) (-9 10 ) = (14 10 ) <= Carries ( 23) (- 9) ( 14) o A Simple Rule for Detecting an Overflow Condition: If the carry in the sign bit equals the carry out of the bit, no overflow has occurred. If the carry into the sign bit is different from the carry out of the sign bit, over (and thus an error) has occurred. o EXAMPLE 2.22 Find the sum of and 8 10 in binary using two s complement arithmetic ( ) (8 10 ) = ( ) <= Carries ( 126) ( 8) (-122) A one is carried into the leftmost bit, but a zero is carried out. Because these carries are not equal, an overflow has occurred. CMPS375 Class Notes (Chap02) Page 6 / 20 by Kuo-pao Yang

7 o N bits can represent (2 n-1 ) to 2 n-1-1. With signed-magnitude number, for example, 4 bits allow us to represent the value -7 through +7. However using two s complement, we can represent the value -8 through +7. Integer Multiplication and Division o For each digit in the multiplier, the multiplicand is shifted one bit to the left. When the multiplier is 1, the shifted multiplicand is added to a running sum of partial products. o EXAMPLE Find the product of (6 10 ) and (11 10 ) ( 6) x (11) Multiplicand Partial Products (1; add multiplicand and shift left) (1; add multiplicand and shift left) (0; Don t add, just shift multiplicand left) (1; add multiplicand and shift left) = (Product; 6 X 11 = 66) o When the divisor is much smaller than the dividend, we get a condition known as divide underflow, which the computer sees as the equivalent of division by zero. o Computer makes a distinction between integer division and floating-point division. With integer division, the answer comes in two parts: a quotient and a remainder. Floating-point division results in a number that is expressed as a binary fraction. Floating-point calculations are carried out in dedicated circuits call floatingpoint units, or FPU Unsigned Versus Signed Numbers 66 If the 4-bit binary value 1101 is unsigned, then it represents the decimal value 13, but as a signed two s complement number, it represents -3. C programming language has int and unsigned int as possible types for integer variables. If we are using 4-bit unsigned binary numbers and we add 1 to 1111, we get 0000 ( return to zero ). If we add 1 to the largest positive 4-bit two s complement number 0111 (+7), we get 1000 (-8). CMPS375 Class Notes (Chap02) Page 7 / 20 by Kuo-pao Yang

8 2.4.4 Computers, Arithmetic, and Booth s Algorithm 66 Consider the following standard pencil and paper method for multiplying two s complement numbers (-5 X -4): 1011 (-5) x 1100 (-4) (0 in multiplier means simple shift) (0 in multiplier means simple shift) (1 in multiplier means add multiplicand and shift) (1 in multiplier means add multiplicand and shift) (-4 X -5 = -124) Note that: Regular multiplication clearly yields the incorrect result. Research into finding better arithmetic algorithms has continued apace for over 50 years. One of the many interesting products of this work is Booth s algorithm. In most cases, Booth s algorithm carries out multiplication faster and more accurately than naïve pencil-and-paper methods. The general idea of Booth s algorithm is to increase the speed of a multiplication when there are consecutive zeros or ones in the multiplier. Consider the following standard multiplication example (3 X 6): 0011 (3) x 0110 (6) (0 in multiplier means simple shift) (1 in multiplier means add multiplicand and shift) (1 in multiplier means add multiplicand and shift) (0 in multiplier means simple shift) (3 X 6 = 18) CMPS375 Class Notes (Chap02) Page 8 / 20 by Kuo-pao Yang

9 In Booth s algorithm, if the multiplicand and multiplier are n-bit two s complement numbers, the result is a 2n-bit two s complement value. Therefore, when we perform our intermediate steps, we must extend our n-bit numbers to 2n-bit numbers. For example, the 4-bit number 1000 (-8) extended to 8 bits would be Booth s algorithm is interested in pairs of bits in the multiplier and proceed according to the following rules: o If the current multiplier bit is 1 and the preceding bit was, we are at the beginning of a string of ones, so subtract (10 pair) the multiplicand form the product. o If the current multiplier bit is 0 and the preceding bit was 1, we are at the end of a string of ones, so we add (01 pair) the multiplicand to the product. o If it is a 00 pair, or a 11 pair, do no arithmetic operation (we are in the middle of a string of zeros or a string of ones). Simply shift. The power of the algorithm is in this step: we can now treat a string of ones as a string of zeros and do nothing more than shift (3) x 0110 (6) (00 = simple shift; assume a mythical 0 as the previous bit) (10 = subtract = add , extend sign) (11 simple shift) (01 = add ) (3 X 6 = 18; 010 ignore extended sign bit that go beyond 2n) Note that: 010 Ignore extended sign bit that go beyond 2n. EXAMPLE 2.23 (-3 X 5) Negative 3 in 4-bit two s complement is Extended to 8 bits, it is Its complement is When we see the rightmost 1 in the multiplier, it is the beginning of a string of 1s, so we treat it as if it were the string 10: 1101 (-3; for subtracting, we will add -3 s complement, or ) x 0101 (5) (10 = subtract 1101 = add ) (01 = add to product: note sign extension) (10 = subtract 1101 = add ) (01 = add to product) (-3 X 5 = -15; using the 8 rightmost bits, or -15) Note that: Ignore extended sign bit that go beyond 2n. CMPS375 Class Notes (Chap02) Page 9 / 20 by Kuo-pao Yang

10 EXAMPLE 2.24 Let s look at the larger example of 53 X 126: (53; for subtracting, we will add the complement of 53 or ) x (126) (00 = simple shift) (10 = subtract = add , sign extension) (11 = simple shift) (11 = simple shift) (11 = simple shift) (11 = simple shift) (11 = simple shift) (01 = add , sign extension) (53 X 126 = 6678; using the 16 rightmost bits) Note that: Ignore extended sign bit that go beyond 2n. Booth s algorithm not only allows multiplication to be performed faster in most cases, but it also has the added bonus in that it works correctly on signed numbers Carry Versus Overflow 70 For unsigned numbers, a carry (out of the leftmost bit) indicates the total number of bits was not large enough to hold the resulting value, and overflow has occurred. For signed numbers, if the carry in to the sign bit and the carry (out of the sign bit) differ, then overflow has occurred. TABLE 2.2 Examples of Carry and Overflow in Signed Numbers CMPS375 Class Notes (Chap02) Page 10 / 20 by Kuo-pao Yang

11 2.4.6 Binary Multiplication and Division Using Shifting 71 We can do binary multiplication and division by 2 very easily using an arithmetic shift operation A left arithmetic shift inserts a 0 in for the rightmost bit and shifts everything else left one bit; in effect, it multiplies by 2 A right arithmetic shift shifts everything one bit to the right, but copies the sign bit; it divides by 2 EXAMPLE 2.25: Multiply the value 11 (expressed using 8-bit signed two s complement representation) by 2. We start with the binary value for 11: (+11) We shift left one place, resulting in: (+22) The sign bit has not changed, so the value is valid. To multiply 11 by 4, we simply perform a left shift twice. EXAMPLE 2.28: Divide the value 12 (expressed using 8-bit signed two s complement representation) by 2. We start with the binary value for 12: (+12) We shift left one place, resulting in: (+6) (Remember, we carry the sign bit to the left as we shift.) To divide 12 by 4, we right shift twice. CMPS375 Class Notes (Chap02) Page 11 / 20 by Kuo-pao Yang

12 2.5 Floating-Point Representation 73 In scientific notion, numbers are expressed in two parts: a fractional part call a mantissa, and an exponential part that indicates the power of ten to which the mantissa should be raised to obtain the value we need A Simple Model 74 In digital computers, floating-point number consist of three parts: a sign bit, an exponent part (representing the exponent on a power of 2), and a fractional part called a significand (which is a fancy word for a mantissa). 1 bit 5 bits 8 bits Sign bit Exponent Significand Unbiased Exponent FIGURE 2.1 Simple Model Floating-Point Representation = * = * 2 17 Biased Exponent: We select 16 because it is midway between 0 and 31 (our exponent has 5 bits, thus allowing for 2 5 or 32 values). Any number larger than 16 in the exponent field will represent a positive value. Value less than 16 will indicate negative values = * 2 5 The biased exponent is = = * 2-1 EXAMPLE 2.31 A normalized form is used for storing a floating-point number in memory. A normalized form is a floating-point representation where the leftmost bit of the significand will always be a 1. Example: Internal representation of (10.25) 10 (10.25) 10 = ( ) 2 (Un-normalized form) = ( ) 2 x 2 0. = ( ) 2 x 2 1. : = ( ) 2 x 2 4 (Normalized form) = ( ) 2 x 2 5 (Un-normalized form) = ( ) 2 x 2 6. Internal representation of (10.25) 10 is CMPS375 Class Notes (Chap02) Page 12 / 20 by Kuo-pao Yang

13 2.5.2 Floating-Point Arithmetic 76 EXAMPLE 2.32: Add the following binary numbers as represented in a normalized 14-bit format, using the simple model with a bias of Renormalizing we retain the larger exponent and truncate the low-order bit EXAMPLE 2.33 Multiply: X = X 2 2 = X x Renormalizing * 2 2 = * 2 1 we retain the larger exponent and truncate the low-order bit Floating-Point Errors 78 We intuitively understand that we are working in the system of real number. We know that this system is infinite. Computers are finite systems, with finite storage. The more bits we use, the better the approximation. However, there is always some element of error, no matter how many bits we use. CMPS375 Class Notes (Chap02) Page 13 / 20 by Kuo-pao Yang

14 2.5.4 The IEEE-754 Floating-Point Standard 79 The IEEE-754 single precision floating point standard uses bias of 127 over its 8-bit exponent. An exponent of 255 indicates a special value. The double precision standard has a bias of 1023 over its 11-bit exponent. The special exponent value for a double precision number is 2047, instead of the 255 used by the single precision standard. Special bit patterns in IEEE Range, Precision, and Accuracy 81 The range of a numeric integer format is the difference between the largest and smallest values that is can express. The precision of a number indicates how much information we have about a value Accuracy refers to how closely a numeric representation approximates a true value Additional Problems with Floating-Point Numbers 82 Because of truncated bits, you cannot always assume that a particular floating point operation is commutative or distributive. This means that we cannot assume: (a + b) + c = a + (b + c) or a * (b + c) = ab + ac CMPS375 Class Notes (Chap02) Page 14 / 20 by Kuo-pao Yang

15 2.6 Character Codes 85 Thus, human-understandable characters must be converted to computerunderstandable bit patterns using some sort of character encoding scheme Binary-Coded Decimal 86 Binary-coded Decimal (BCD) is a numeric coding system used primarily in IBM mainframe and midrange systems in the 1950s and 1960s. BCD is very common in electronics, particularly those that display numerical data, such as alarm clocks and calculators. BCD encodes each digit of a decimal number into a 4-bit binary form. When stored in an 8-bit byte, the upper nibble is called the zone and the lower part is called the digit EBCDIC 87 TABLE 2.5 Binary-Coded Decimal In 1964, BCD was extended to an 8-bit code, Extended Binary-Coded Decimal Interchange Code (EBCDIC). EBCDIC was one of the first widely-used computer codes that supported upper and lowercase alphabetic characters, in addition to special characters, such as punctuation and control characters. EBCDIC and BCD are still in use by IBM mainframes today. See Page 77 TABLE 2.6 CMPS375 Class Notes (Chap02) Page 15 / 20 by Kuo-pao Yang

16 2.6.3 ASCII 88 ASCII: American Standard Code for Information Interchange In 1967, a derivative of this alphabet became the official standard that we now call ASCII Unicode 88 Both EBCDIC and ASCII were built around the Latin alphabet. In 1991, a new international information exchange code called Unicode. Unicode is a 16-bit alphabet that is downward compatible with ASCII and Latin-1 character set. Because the base coding of Unicode is 16 bits, it has the capacity to encode the majority of characters used in every language of the world. Unicode is currently the default character set of the Java programming language. TABLE 2.8 Unicode Codespace The Unicode codespace is divided into six parts. The first part is for Western alphabet codes, including English, Greek, and Russian. The lowest-numbered Unicode characters comprise the ASCII code. The highest provide for user-defined codes. CMPS375 Class Notes (Chap02) Page 16 / 20 by Kuo-pao Yang

17 2.7 Error Detection and Correction 92 No communications channel or storage medium can be completely error-free Cyclic Redundancy Check 92 Cyclic redundancy check (CRC) is a type of checksum used primarily in data communications that determines whether an error has occurred within a large block or stream of information bytes. Arithmetic Modulo 2The rules are as follows: = = = = 0 EXAMPLE 2.35 Find the sum of and modulo = (mod 2) EXAMPLE 2.36 Find the quotient and remainder when is divided by Quotient and Remainder Calculating and Using CRC o Suppose we want to transmit the information string: o The receiver and sender decide to use the (arbitrary) polynomial pattern, o The information string is shifted left by one position less than the number of positions in the divisor. I = o The remainder is found through modulo 2 division (at right) and added to the information string: = o If no bits are lost or corrupted, dividing the received information string by the agreed upon pattern will give a remainder of zero. o We see this is so in the calculation at the right. o Real applications use longer polynomials to cover larger information strings. A remainder other than zero indicates that an error has occurred in the transmission. This method work best when a large prime polynomial is used. There are four standard polynomials used widely for this purpose: o CRC-CCITT (ITU-T): X 16 + X 12 + X o CRC-12: X 12 + X 11 + X 3 + X 2 + X + 1 o CRC-16 (ANSI): X 16 + X 15 + X o CRC-32: X 32 + X 26 + X 23 + X 22 + X 16 + X 12 + X 11 + X 10 + X 8 + X 7 + X 6 + X 4 + X + 1 CRC-32 has been proven that CRCs using these polynomials can detect over 99.8% of all single-bit errors. CMPS375 Class Notes (Chap02) Page 17 / 20 by Kuo-pao Yang

18 2.7.2 Hamming Codes 95 Data communications channels are simultaneously more error-prone and more tolerant of errors than disk systems. Hamming code use parity bits, also called check bits or redundant bits. The final word, called a code word is an n-bit unit containing m data bits and r check bits. n = m + r The Hamming distance between two code words is the number of bits in which two code words differ *** Hamming distance of these two code words is 3 The minimum Hamming distance, D(min), for a code is the smallest Hamming distance between all pairs of words in the code. Hamming codes can detect (D(min) - 1) errors and correct [(D(min) 1) / 2] errors. EXAMPLE 2.37 EXAMPLE D(min) = 3. Thus, this code can detect up to two errors and correct one single bit error. We are focused on single bit error. An error could occur in any of the n bits, so each code word can be associated with n erroneous words at a Hamming distance of 1. Therefore, we have n + 1 bit patterns for each code word: one valid code word, and n erroneous words. With n-bit code words, we have 2 n possible code words consisting of 2 m data bits (where m = n + r). This gives us the inequality: (n + 1) * 2 m < = 2 n Because m = n + r, we can rewrite the inequality as: (m + r + 1) * 2 m <= 2 m + r or (m + r + 1) <= 2 r CMPS375 Class Notes (Chap02) Page 18 / 20 by Kuo-pao Yang

19 EXAMPLE 2.39 Using the Hamming code just described and even parity, encode the 8-bit ASCII character K. (The high-order bit will be zero.) Induce a single-bit error and then indicate how to locate the error. m = 8, we have (8 + r + 1) <= 2 r then We choose r = 4 Parity bit at 1, 2, 4, 8 Char K = = 1 5 = = = 2 6 = = = = = = 4 8 = 8 12 = We have the following code word as a result: Parity b1 = b3 + b5 + b7 + b9 + b11 = = 0 Parity b2 = b3 + b6 + b7 + b10 + b11 = = 1 Parity b4 = b5 + b6 + b7 + b12 = = 0 Parity b8 = b9 + b10 + b11 + b12 = = 1 Let s introduce an error in bit position b9, resulting in the code word: Parity b1 = b3 + b5 + b7 + b9 + b11 = = 1 (Error, should be 0) Parity b2 = b3 + b6 + b7 + b10 + b11 = = 1 (OK) Parity b4 = b5 + b6 + b7 + b12 = = 0 (OK) Parity b8 = b9 + b10 + b11 + b12 = = 0 (Error, should be 1) We found that parity bits 1 and 8 produced an error, and = 9, which in exactly where the error occurred. CMPS375 Class Notes (Chap02) Page 19 / 20 by Kuo-pao Yang

20 2.7.3 Reed-Soloman 102 If we expect errors to occur in blocks, it stands to reason that we should use an errorcorrecting code that operates at a block level, as opposed to a Hamming code, which operates at the bit level. A Reed-Soloman (RS) code can be thought of as a CRC that operates over entire characters instead of only a few bits. RS codes, like CRCs, are systematic: The parity bytes are append to a block of information bytes. RS (n, k) code are defined using the following parameters: o s = The number of bits in a character (or symbol ). o k = The number of s-bit characters comprising the data block. o n = The number of bits in the code word. RS (n, k) can correct (n-k)/2 errors in the k information bytes. Reed-Soloman error-correction algorithms lend themselves well to implementation in computer hardware. They are implemented in high-performance disk drives for mainframe computers as well as compact disks used for music and data storage. These implementations will be described in Chapter 7. Chapter Summary 103 Computers store data in the form of bits, bytes, and words using the binary numbering system. Hexadecimal numbers are formed using four-bit groups called nibbles (or nybbles). Signed integers can be stored in one s complement, two s complement, or signed magnitude representation. Floating-point numbers are usually coded using the IEEE 754 floating-point standard. Character data is stored using ASCII, EBCDIC, or Unicode. Error detecting and correcting codes are necessary because we can expect no transmission or storage medium to be perfect. CRC, Reed-Soloman, and Hamming codes are three important error control codes. CMPS375 Class Notes (Chap02) Page 20 / 20 by Kuo-pao Yang

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

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

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

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

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

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

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

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

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

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

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

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

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

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

### Chapter 4: Computer Codes

Slide 1/30 Learning Objectives In this chapter you will learn about: Computer data Computer codes: representation of data in binary Most commonly used computer codes Collating sequence 36 Slide 2/30 Data

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

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

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

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

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

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

### Sheet 7 (Chapter 10)

King Saud University College of Computer and Information Sciences Department of Information Technology CAP240 First semester 1430/1431 Multiple-choice Questions Sheet 7 (Chapter 10) 1. Which error detection

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

### Encoding Text with a Small Alphabet

Chapter 2 Encoding Text with a Small Alphabet Given the nature of the Internet, we can break the process of understanding how information is transmitted into two components. First, we have to figure out

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

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

### Lecture 4 Representing Data on the Computer. Ramani Duraiswami AMSC/CMSC 662 Fall 2009

Lecture 4 Representing Data on the Computer Ramani Duraiswami AMSC/CMSC 662 Fall 2009 x = ±(1+f) 2 e 0 f < 1 f = (integer < 2 52 )/ 2 52-1022 e 1023 e = integer Effects of floating point Effects of floating

### 2. Compressing data to reduce the amount of transmitted data (e.g., to save money).

Presentation Layer The presentation layer is concerned with preserving the meaning of information sent across a network. The presentation layer may represent (encode) the data in various ways (e.g., data

### Binary. ! You are probably familiar with decimal

Arithmetic operations in assembly language Prof. Gustavo Alonso Computer Science Department ETH Zürich alonso@inf.ethz.ch http://www.inf.ethz.ch/department/is/iks/ Binary! You are probably familiar with

### Activity 1: Bits and Bytes

ICS3U (Java): Introduction to Computer Science, Grade 11, University Preparation Activity 1: Bits and Bytes The Binary Number System Computers use electrical circuits that include many transistors and

### DNA Data and Program Representation. Alexandre David 1.2.05 adavid@cs.aau.dk

DNA Data and Program Representation Alexandre David 1.2.05 adavid@cs.aau.dk Introduction Very important to understand how data is represented. operations limits precision Digital logic built on 2-valued

### CHAPTER 3 Boolean Algebra and Digital Logic

CHAPTER 3 Boolean Algebra and Digital Logic 3.1 Introduction 121 3.2 Boolean Algebra 122 3.2.1 Boolean Expressions 123 3.2.2 Boolean Identities 124 3.2.3 Simplification of Boolean Expressions 126 3.2.4

### Digital Logic Design. Introduction

Digital Logic Design Introduction A digital computer stores data in terms of digits (numbers) and proceeds in discrete steps from one state to the next. The states of a digital computer typically involve

### COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

Binary numbers The reason humans represent numbers using decimal (the ten digits from 0,1,... 9) is that we have ten fingers. There is no other reason than that. There is nothing special otherwise about

### Review 1/2. CS61C Characters and Floating Point. Lecture 8. February 12, Review 2/2 : 12 new instructions Arithmetic:

Review 1/2 CS61C Characters and Floating Point Lecture 8 February 12, 1999 Handling case when number is too big for representation (overflow) Representing negative numbers (2 s complement) Comparing signed

### The finite field with 2 elements The simplest finite field is

The finite field with 2 elements The simplest finite field is GF (2) = F 2 = {0, 1} = Z/2 It has addition and multiplication + and defined to be 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 0 0 0 = 0 0 1 = 0

### Correctly Rounded Floating-point Binary-to-Decimal and Decimal-to-Binary Conversion Routines in Standard ML. By Prashanth Tilleti

Correctly Rounded Floating-point Binary-to-Decimal and Decimal-to-Binary Conversion Routines in Standard ML By Prashanth Tilleti Advisor Dr. Matthew Fluet Department of Computer Science B. Thomas Golisano

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

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

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

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

### MODULAR ARITHMETIC. a smallest member. It is equivalent to the Principle of Mathematical Induction.

MODULAR ARITHMETIC 1 Working With Integers The usual arithmetic operations of addition, subtraction and multiplication can be performed on integers, and the result is always another integer Division, on

### Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating

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

### Bits, bytes, and representation of information

Bits, bytes, and representation of information digital representation means that everything is represented by numbers only the usual sequence: something (sound, pictures, text, instructions,...) is converted

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

### CS201: Architecture and Assembly Language

CS201: Architecture and Assembly Language Lecture Three Brendan Burns CS201: Lecture Three p.1/27 Arithmetic for computers Previously we saw how we could represent unsigned numbers in binary and how binary

### Primitive Data Types Summer 2010 Margaret Reid-Miller

Primitive Data Types 15-110 Summer 2010 Margaret Reid-Miller Data Types Data stored in memory is a string of bits (0 or 1). What does 1000010 mean? 66? 'B'? 9.2E-44? How the computer interprets the string

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

### Numerical Matrix Analysis

Numerical Matrix Analysis Lecture Notes #10 Conditioning and / Peter Blomgren, blomgren.peter@gmail.com Department of Mathematics and Statistics Dynamical Systems Group Computational Sciences Research

### Copy in your notebook: Add an example of each term with the symbols used in algebra 2 if there are any.

Algebra 2 - Chapter Prerequisites Vocabulary Copy in your notebook: Add an example of each term with the symbols used in algebra 2 if there are any. P1 p. 1 1. counting(natural) numbers - {1,2,3,4,...}

### COMPASS Numerical Skills/Pre-Algebra Preparation Guide. Introduction Operations with Integers Absolute Value of Numbers 13

COMPASS Numerical Skills/Pre-Algebra Preparation Guide Please note that the guide is for reference only and that it does not represent an exact match with the assessment content. The Assessment Centre

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

### 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 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 Link Layer(1) Principal service: Transferring data from the network layer of the source machine to the one of the destination machine

Data Link Layer(1) Principal service: Transferring data from the network layer of the source machine to the one of the destination machine Virtual communication versus actual communication: Specific functions

### Borland C++ Compiler: Operators

Introduction Borland C++ Compiler: Operators An operator is a symbol that specifies which operation to perform in a statement or expression. An operand is one of the inputs of an operator. For example,

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

### ASCII Characters. 146 CHAPTER 3 Information Representation. The sign bit is 1, so the number is negative. Converting to decimal gives

146 CHAPTER 3 Information Representation The sign bit is 1, so the number is negative. Converting to decimal gives 37A (hex) = 134 (dec) Notice that the hexadecimal number is not written with a negative

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

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

### Intel Hexadecimal Object File Format Specification Revision A, 1/6/88

Intel Hexadecimal Object File Format Specification Revision A, 1/6/88 DISCLAIMER Intel makes no representation or warranties with respect to the contents hereof and specifically disclaims any implied warranties

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

### TYPES OF NUMBERS. Example 2. Example 1. Problems. Answers

TYPES OF NUMBERS When two or more integers are multiplied together, each number is a factor of the product. Nonnegative integers that have exactly two factors, namely, one and itself, are called prime

### Bits and Bytes. Computer Literacy Lecture 4 29/09/2008

Bits and Bytes Computer Literacy Lecture 4 29/09/2008 Lecture Overview Lecture Topics How computers encode information How to quantify information and memory How to represent and communicate binary data

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

Modbus Frequently Asked Questions WP-34-REV0-0609-1/7 The Answer to the 14 Most Frequently Asked Modbus Questions Exactly what is Modbus? Modbus is an open serial communications protocol widely used in

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

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