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

Size: px
Start display at page:

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

Transcription

1 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 we mean expressions such as 10 Megabytes, 45 Kilobytes, and 200Gigahertz (a byte is eight binary digits treated as a group to represent a single quantity. A byte of storage is typically required to store a single alphanumeric character.) 2 0 =1 =1 2 5 =32 = =2 = =64 = =4 = =128 = =8 = =256 = =16 = =512 = Large quantities are generally given in powers of two, but also have English names commonly associated with powers of ten. For instance, 1 Kilobyte is not 1000 (10 3 ) bytes, but is 2 10 (1024) bytes and is referred to as a kilobyte, or 1KB. In computer science, the phrase one thousand will usually mean , not Similarly, a million is 2 20 and a billion is 2 30 ; 2 20 bytes is called a megabyte (1 MB), and 2 30 bytes is a gigabyte (1 GB) =1024=1K =1M 2 30 =1G To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic: Examples: 2 a+b = 2 a x 2 b 2 a-b = 2 a /2 b 2 -a = 1/2 a 12. Converting binary exponential expressions to 'English'abbreviation 2 12 = 2 2 x 2 10 = 4 x 1K = 4K 3 Note, Kilobyte is denoted by KB (and Kilobit is denoted by Kb). The K, M, and G identify only the prefixes, since we may count other things besides bytes. NTC 1/23/05 21

2 2 33 = 2 3 x 2 30 = 8 x 1G = 8G 2 27 = 2 7 x 2 20 = 128 x 1M = 128M 13. Converting 'English'abbreviations to binary exponential expressions. 32G = 32 x 1G = 2 5 x 2 30 = K = 16 x 1K = 2 4 x 2 10 = M = 512 x 1M = 2 9 x 2 20 = 2 29 Practice Problems - Binary-to-English Conversions 1. Convert the following binary exponential expressions to their 'English' counterparts: Convert the following 'English'expressions to their binary exponential equivalents: 3. Word problems 1K M 32K 128G 2M 4G 512K 8M a. How much memory is supported by a system with 24-bit memory addresses? b. How large an address is needed to address a memory of 4GB? c. How many op code bits are need in an instruction which supports 128 different operations? d. How many registers are supported by an instruction with a register ID field of 6 bits? Binary Number Conversion We will frequently have occasion to convert binary numbers to decimal numbers. The techniques previously described for number systems in general are fully applicable here. For example, converting binary to decimal: = 1x x x x x x x2 0 NTC 1/23/05 22

3 = = =1x x x2-3 = 1/ / /2 3 = 1/2 + 0/4 + 1/8 = (4+1)/8 = 5/8 = For the interested student, note that there are ways to speed up the conversion of integer binary numbers to decimal. They rely on two things. First that you memorized the decimal/binary equivalents of the numbers 0 thru 15, as shown in table TN1; second, remember that shifting a binary number one position to the left (inserting a zero in the rightmost postion) multiplies that number by 2 (just as shifting a decimal number to the left multiplies it by 10). Then could be rapidly converted as follows: = = 11 x since the first 4 digits (1011 = 11) are shifted 3 places (=8) = or, equivalently, = = 10 x = Examples of converting decimal to binary: to binary - 91/2 = 45 with a remainder of 1 45/2 = 22 with a remainder of 1 22/2 = 11 with a remainder of 0 11/2 = 5 with a remainder of 1 5/2 = 2 with a remainder of 1 2/2 = 1 with a remainder of 0 1/2 = 0 with a remainder of 1 giving to binary -.75 x 2 = 1.50 first digit is 1.50 x 2 = 1.00 second digit is 1.00 x 2 = 0 we are done giving.11 2 NTC 1/23/05 23

4 Alternatively, some students find it faster to use the following scheme for converting decimal integer numbers to binary. Simply find the largest power of 2 which is smaller than or equal to the given number (you should have memorized the first 10 powers of 2), and subtract this power of two from the number. Continue subtracting powers of two from the result of the previous subtraction until the result is zero. The powers of 2 which were able to be subtracted are then the positions of all the 1's in the result. Example, = 27 Therefore 64 = 2 6 is the position of the first = 11 Therefore 16 = 2 4 is the position of the second = 3 8 = 2 3 is the third position 3-2 = 1 2 = 2 1 is the fourth position 1-1 = 0 1 =2 0 is the fifth 1 in the answer giving Negative Binary Numbers In what follows, keep in mind that, since we are interested in using these numbers within the hardware of a computer, there is a finite amount (usually small) of space (storage) allocated for each number. In the computer s memory this may be referred to as a word. In the CPU such data is held in storage devices called registers. Each register has a finite size, measured in bits, where each bit is a binary digit (in fact, the word bit is a contraction of the words binary digit. We assume that every binary number uses all the bits available in the specified register. A group of adjacent 8 bits in a register is called a byte. A 32-bit register, therefore, is also a 4-byte register. There are six common ways of representing a number in binary: Unsigned Sign and Magnitude 2's complement Biased Binary Coded Decimal Floating Point The second, third and fourth are binary representations which allow for the representation of negative as well as positive numbers. 5. Unsigned binary numbers. All the bits in the register are weighted per there bit positions, and are numbered 0 through n-1 from right to left. If the register is n NTC 1/23/05 24

5 bits wide, it can hold 2 n different values, in the range (assuming integers only) of 0 through +2 n - 1. For example, a 16-bit register holds 2 16 = values, 0 thru Note that all arithmetic results which end up in an n-bit register can never have a value greater than 2 n - 1, and is thus effectively arithmetic modulo 2 n. Keep this in mind for future discussion. 6. Sign and Magnitude. In this convention, only bits 0 through n-2 are used to hold the number, bit n-1 (the most significant bit) is used to specify the sign of the number. A zero in position n-1 means that the number is positive, a one in position n-1 means that the number is negative. In an eight bit register, for example, bit 7 represents the sign. The number is the number (the same as if the number were unsigned), and is (this would be if it were an unsigned number). The range of values able to be represented in this form is -(2 n-1-1) through +2 n-1-1. The values in a 16 bit register are thru One problem with this convention is that 0 10 has two representations: and 's complement. Both 2's complement and 1's complement may be used to incorporate both positive and negative number representations in a computer; we will focus on 2's complement for reasons that will become clear later. As in the previously mentioned conventions, positive numbers (and zero) are represented normally, just as if they were unsigned binary numbers. However, the negative of a number in 2's complement form is simply the value you get when you subtract the positive representation of the number from 2 n. That is, if x is binary n-bit number, then -x = 2 n - x [N10] There is a simple way to perform this operation without actually having to do subtraction, consisting of a two step process as follows: i. Complement the value. That is, change every 1 to a 0 and every 0 to a 1. ii. Add 1 to the result of the first step. For example, in an eight bit register, the number is given by Complementing this gives Adding 1 gives which is used to represent Recall that when converting a binary number to a decimal number, we simply add up all the weighted values of the positions in the binary where there is a 1. To convert a 2's complement number, the same procedure is applied, but the weight NTC 1/23/05 25

6 of the (n-1) st bit (the most significant bit) has a weight of -2 n-1 instead of +2 n-1!. Thus the decimal value of the four-bit 2's complement number 1110 is = = -2. The range of values able to be represented in 2's complement is -2 n-1 through +2 n This is one more negative value than is represented by the sign & magnitude representation, corresponding to the fact that there is only one representation for zero. Note 1: When this convention is being used, all numbers are considered 2's complement numbers, regardless of whether they are positive or negative. Don t fall into the trap of thinking that only the negative numbers are in 2's complement. Note 2: Negative numbers can be converted to positive numbers using the exact same procedure: complement and add 1 (i.e. you don t have to do the operations in reverse by subtracting 1 and then complementing). Note 3: Negative numbers will always have a leading 1, positive numbers will always have a leading 0. If you are asked to convert a positive decimal number to a 2's complement number, don t forget to add the leading 0! Note 4: When a positive n-bit number and its negative representation (in 2's complement form) are added together, the result is 2 n (see N10]). Since the maximum value an n-bit register can hold is 2 n -1, the result is all zeros in the register and an overflow (This is an addition modulo 2 n ). We ignore the overflow and get the correct result: zero. As we will see this is important for implementing binary arithmetic. Note 5: A 2's complement integer n bits in length can be represented similarly to [N8] except that the weight of the most significant bit is negative. N = (- d n-1 x -2 n-1 ) + d i 2 i [N11] Radix Conversion of 2's complement numbers. Decimal to 2's Complement Conversion Converting a positive decimal number to 2's complement form is identical to converting it to an unsigned binary number, except that you must be sure to include a leading zero. Example 14: Represent in 2's complement notation NTC 1/23/05 26

7 = , not (which would be - 13) To convert a negative decimal number to 2's complement form a. Convert the number to binary, assuming it is positive, as above; b. Use the complement-and-add procedure to convert the positive 2's complement number into a negative 2's complement number. Example 15: Represent in 2's complement notation. a. +19 = (remember to include the leading 0!) b. complement and add: = 's Complement to Decimal Conversion To convert a binary 2's complement number (regardless of sign) to decimal, use [N11]. That is, sum up the weights of all the positions containing a one, except that the weight of the most significant bit is negative. Example: = = = = Value of bit n-1 Value of remainin g bits Example : +19 Unsigned d n-1 2 n-1 d i r i n/a Sign & Magnitude Example : -19 sign d i r i 's Complement -d n-1 2 n-1 d i r i Table TN2. Table TN2 summarizes these number formats and includes the previous examples. Notice that these formats differ only in the interpretation of the most significant bit position (2 n-1 ), and that positive numbers have the same representation regardless of format (although the leading 0 is not required if the number is known to be in unsigned format.) NTC 1/23/05 27

8 Practice problems - 2's Complement Numbers: 1. Given the binary number , what is its decimal value if it is a a. unsigned binary number (Ans: 219) b. sign and complement number (Ans: -91) c. 2's complement number (Ans: -37) 2. Convert +24 into a 2's complement number (Ans: Note the leading zero!) 3. Convert -24 into a 2's complement number (Ans: ) 4. Convert -1 into a 2's complement number (assume a 4-bit result) (Ans: 1111) Note that -1 is regardless of the size of the register. Note also that any positive or negative 2's complement number can have its leading digit propagated to the left without changing the number. 5. What is the minimum (maximum negative) number which can be represented using a 6-bit 2's Complement representation? What is the maximum (positive) number? 6. What is the minimum (maximum negative) number which can be represented using a n-bit 2's Complement representation? What is the maximum (positive) number? Convert, if possible, the following decimal numbers to 2's complement assuming an 8-bit binary representation for all Convert the following 2's complement numbers to decimal NTC 1/23/05 28

9 Biased numbers - It is sometimes desirable (we ll see an example in a bit) to have the range of negative and positive numbers by monotonically increasing - that is, each successive number is determined by adding one to the previous number. Basically, we take our numerical sequence, and shift the meanings of the combinations of ones and zero so that some of the combinations are negative in interpretation. For example, using three bit binary numbers: binary unsigned Bias(3) Notice that the decimal values have been shifted down (or biased by) 3 positions, eliminating the values 5 thru 7 and inserting the values -3 thru -1. The value of the bias is usually chosen to be roughly one half of the total range of numbers available, which is determined by the number of bits allocated to the number. In the above example, three bits give a total of eight numbers, 0 thru 7; we would generally choose a bias of three or four, depending on whether we wanted more positive or negative numbers. In general, for the purposes of this text, choose a bias as follows: 1. Given the maximum number of binary bits, n, choose a bias 4 = 2 n /2 = 2 n-1 If n = 8, the bias should be 128 ( = 2 8 /2 = 256/2 = 128 = = 2 7 If n = 16, the bias should be 2 16 /2 = 32K 2. Given a negative decimal number, assume a bias equal to the minimum power 4 In practice, the bias is general chosen to be 1 less then the values presented here. For instance, as we will see, the IEEE single-precision floating point specification, which uses a biased 8 bit number for the exponent representation uses a bias of 127, not 128. NTC 1/23/05 29

10 of two greater than the absolute value of the negative decimal number. Also, if 2m is the bias, then the number of bits in the biased representation must be m+1. This is because, if the bias is 2 m, then the range of numbers to be represented is - 2 m -1 thru +2 m for a total range of 2 x 2 m = 2 m+1. This requires m+1 bits in the binary biased representation. If the negative decimal number is -23 assume a bias equal to 32. The number of bits in the biased representation will be 6. If the negative decimal number is -129 assume a bias equal to 256. The number of bits in the biased representation will be 9. Converting Decimal numbers to Biased binary numbers Examples: 1. Add the bias to the decimal number 2. convert the resulting decimal number to binary 16. Assume a five-bit biased binary representation. What bias would you use? (Ans. 15 or 16, usually 15). 17. Using this bias, convert the decimal numbers 0, 6, and -12 to biased format. Ans: = 15 = = 21 = = 3 = Convert -49 to biased binary representation. Choose a bias equal to 2 m such that 2 m > 49. In this case, the bias = 64. Then a. Add the bias: = 15 b. Convert the result to binary: = Notice that, since 2 m = 64, m = 6 and the binary representation must contain m+1 bit positions (7 in this case). Converting biased binary numbers to decimal 1. Convert the biased binary number to decimal NTC 1/23/05 30

11 Examples: 2. Subtract the bias from the resulting decimal number 19. Convert the biased binary number to decimal Since there are 6 binary digits, assume the bias is 2 6 /2 = 2 5 =32 1. Convert to decimal: = Subtract the bias: = Convert the biased binary number to decimal. Since there are 8 bits, assume a bias of = = Convert 0001 to decimal. Bias = = = NTC 1/23/05 31

12 Practice Problems - Biased Binary Numbers 1. What bias should you choose for biased binary representations with each of the following number of bits? a. 8 bits b. 2 bits c. 24 bitsd. 13 bits 2. What bias should you choose for biased binary representation of each of the following decimal numbers? a. -10 b c d Convert the following decimal numbers to the appropriate biased binary format. a. -34 b. -12 c d Convert the following biased binary numbers to decimal a. 101 b c d Table TN3 shows the decimal values associated with the binary numbers 0000 through 1111 in each of the binary number representations discussed. NTC 1/23/05 32

13 UNSIGNED BINARY UNSIGNED DECIMAL SIGN & MAGNI- TUDE 2'S COMPL- EMENT BIAS(8) BIAS(7) Table TN3. Note: The above representations of binary numbers seem to refer to only integers. However, a binary point (as opposed to a decimal point) could be assumed to be anywhere in the register holding the number. If we have an eight bit (1 byte) register containing the bits , it might, depending on the application, be interpreted to contain = , or = , or = These are called Fixed Point numbers, in contrast to floating point numbers which will be discussed shortly. Note that shifting a binary number left (and inserting a zero into the least significant digit) is the same as multiplying by 2. Compare this to adding a low order zero to a decimal number. Shifting right performs the DIV 2 operation, since the least significant NTC 1/23/05 33

14 bits are shifted out of the register and are lost = = = NTC 1/23/05 34

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

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

More information

Base Conversion written by Cathy Saxton

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,

More information

Useful Number Systems

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

More information

Computer Science 281 Binary and Hexadecimal Review

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

More information

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

More information

CSI 333 Lecture 1 Number Systems

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

More information

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

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

More information

Lecture 2. Binary and Hexadecimal Numbers

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

More information

Lecture 8: Binary Multiplication & Division

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

More information

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

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

More information

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

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

More information

Number Representation

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

More information

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

More information

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

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

More information

Systems I: Computer Organization and Architecture

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

More information

ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

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

More information

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

More information

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

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.

More information

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

More information

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

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

More information

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

More information

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

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

More information

Binary Adders: Half Adders and Full Adders

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

More information

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

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

More information

Solution for Homework 2

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

More information

Memory is implemented as an array of electronic switches

Memory is implemented as an array of electronic switches Memory Structure Memory is implemented as an array of electronic switches Each switch can be in one of two states 0 or 1, on or off, true or false, purple or gold, sitting or standing BInary digits (bits)

More information

NUMBER SYSTEMS. William Stallings

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

More information

CHAPTER 5 Round-off errors

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

More information

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

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

More information

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

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

More information

Section 1.4 Place Value Systems of Numeration in Other Bases

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

More information

Binary, Hexadecimal, Octal, and BCD Numbers

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

More information

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

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

More information

Counting in base 10, 2 and 16

Counting in base 10, 2 and 16 Counting in base 10, 2 and 16 1. Binary Numbers A super-important fact: (Nearly all) Computers store all information in the form of binary numbers. Numbers, characters, images, music files --- all of these

More information

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

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

More information

Binary Numbering Systems

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

More information

NUMBER SYSTEMS. 1.1 Introduction

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.

More information

Numbering Systems. InThisAppendix...

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

More information

5.1 Radical Notation and Rational Exponents

5.1 Radical Notation and Rational Exponents Section 5.1 Radical Notation and Rational Exponents 1 5.1 Radical Notation and Rational Exponents We now review how exponents can be used to describe not only powers (such as 5 2 and 2 3 ), but also roots

More information

The BBP Algorithm for Pi

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

More information

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

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;

More information

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

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

More information

Lecture 11: Number Systems

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

More information

Binary Representation

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

More information

Chapter 4: Computer Codes

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

More information

Subnetting Examples. There are three types of subnetting examples I will show in this document:

Subnetting Examples. There are three types of subnetting examples I will show in this document: Subnetting Examples There are three types of subnetting examples I will show in this document: 1) Subnetting when given a required number of networks 2) Subnetting when given a required number of clients

More information

CPEN 214 - Digital Logic Design Binary Systems

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

More information

APPENDIX B. Routers route based on the network number. The router that delivers the data packet to the correct destination host uses the host ID.

APPENDIX B. Routers route based on the network number. The router that delivers the data packet to the correct destination host uses the host ID. APPENDIX B IP Subnetting IP Addressing Routers route based on the network number. The router that delivers the data packet to the correct destination host uses the host ID. IP Classes An IP address is

More information

The Hexadecimal Number System and Memory Addressing

The Hexadecimal Number System and Memory Addressing APPENDIX C The Hexadecimal Number System and Memory Addressing U nderstanding the number system and the coding system that computers use to store data and communicate with each other is fundamental to

More information

An Efficient RNS to Binary Converter Using the Moduli Set {2n + 1, 2n, 2n 1}

An Efficient RNS to Binary Converter Using the Moduli Set {2n + 1, 2n, 2n 1} An Efficient RNS to Binary Converter Using the oduli Set {n + 1, n, n 1} Kazeem Alagbe Gbolagade 1,, ember, IEEE and Sorin Dan Cotofana 1, Senior ember IEEE, 1. Computer Engineering Laboratory, Delft University

More information

CS201: Architecture and Assembly Language

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

More information

Data Storage 3.1. Foundations of Computer Science Cengage Learning

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

More information

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

More information

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

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

More information

NUMBER SYSTEMS APPENDIX D. You will learn about the following in this appendix:

NUMBER SYSTEMS APPENDIX D. You will learn about the following in this appendix: APPENDIX D NUMBER SYSTEMS You will learn about the following in this appendix: The four important number systems in computing binary, octal, decimal, and hexadecimal. A number system converter program

More information

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

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

More information

26 Integers: Multiplication, Division, and Order

26 Integers: Multiplication, Division, and Order 26 Integers: Multiplication, Division, and Order Integer multiplication and division are extensions of whole number multiplication and division. In multiplying and dividing integers, the one new issue

More information

COMPSCI 210. Binary Fractions. Agenda & Reading

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

More information

Section 4.1 Rules of Exponents

Section 4.1 Rules of Exponents Section 4.1 Rules of Exponents THE MEANING OF THE EXPONENT The exponent is an abbreviation for repeated multiplication. The repeated number is called a factor. x n means n factors of x. The exponent tells

More information

1 Description of The Simpletron

1 Description of The Simpletron Simulating The Simpletron Computer 50 points 1 Description of The Simpletron In this assignment you will write a program to simulate a fictional computer that we will call the Simpletron. As its name implies

More information

Number and codes in digital systems

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

More information

Recall the process used for adding decimal numbers. 1. Place the numbers to be added in vertical format, aligning the decimal points.

Recall the process used for adding decimal numbers. 1. Place the numbers to be added in vertical format, aligning the decimal points. 2 MODULE 4. DECIMALS 4a Decimal Arithmetic Adding Decimals Recall the process used for adding decimal numbers. Adding Decimals. To add decimal numbers, proceed as follows: 1. Place the numbers to be added

More information

Chapter 2: Basics on computers and digital information coding. A.A. 2012-2013 Information Technology and Arts Organizations

Chapter 2: Basics on computers and digital information coding. A.A. 2012-2013 Information Technology and Arts Organizations Chapter 2: Basics on computers and digital information coding Information Technology and Arts Organizations 1 Syllabus (1/3) 1. Introduction on Information Technologies (IT) and Cultural Heritage (CH)

More information

Number Systems and Radix Conversion

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

More information

Chapter 1: Digital Systems and Binary Numbers

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

More information

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc Other architectures Example. Accumulator-based machines A single register, called the accumulator, stores the operand before the operation, and stores the result after the operation. Load x # into acc

More information

23. RATIONAL EXPONENTS

23. RATIONAL EXPONENTS 23. RATIONAL EXPONENTS renaming radicals rational numbers writing radicals with rational exponents When serious work needs to be done with radicals, they are usually changed to a name that uses exponents,

More information

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

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.

More information

BINARY CODED DECIMAL: B.C.D.

BINARY CODED DECIMAL: B.C.D. BINARY CODED DECIMAL: B.C.D. ANOTHER METHOD TO REPRESENT DECIMAL NUMBERS USEFUL BECAUSE MANY DIGITAL DEVICES PROCESS + DISPLAY NUMBERS IN TENS IN BCD EACH NUMBER IS DEFINED BY A BINARY CODE OF 4 BITS.

More information

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

More information

CS321. Introduction to Numerical Methods

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

More information

2.6 Exponents and Order of Operations

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

More information

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

More information

Session 7 Fractions and Decimals

Session 7 Fractions and Decimals Key Terms in This Session Session 7 Fractions and Decimals Previously Introduced prime number rational numbers New in This Session period repeating decimal terminating decimal Introduction In this session,

More information

We can express this in decimal notation (in contrast to the underline notation we have been using) as follows: 9081 + 900b + 90c = 9001 + 100c + 10b

We can express this in decimal notation (in contrast to the underline notation we have been using) as follows: 9081 + 900b + 90c = 9001 + 100c + 10b In this session, we ll learn how to solve problems related to place value. This is one of the fundamental concepts in arithmetic, something every elementary and middle school mathematics teacher should

More information

1.4 Compound Inequalities

1.4 Compound Inequalities Section 1.4 Compound Inequalities 53 1.4 Compound Inequalities This section discusses a technique that is used to solve compound inequalities, which is a phrase that usually refers to a pair of inequalities

More information

THE BINARY NUMBER SYSTEM

THE BINARY NUMBER SYSTEM THE BINARY NUMBER SYSTEM Dr. Robert P. Webber, Longwood University Our civilization uses the base 10 or decimal place value system. Each digit in a number represents a power of 10. For example, 365.42

More information

3. Convert a number from one number system to another

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

More information

Unsigned Conversions from Decimal or to Decimal and other Number Systems

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

More information

HOMEWORK # 2 SOLUTIO

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

More information

Numerical Matrix Analysis

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

More information

Positional Numbering System

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

More information

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

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 -

More information

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program. Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to

More information

Inequalities - Absolute Value Inequalities

Inequalities - Absolute Value Inequalities 3.3 Inequalities - Absolute Value Inequalities Objective: Solve, graph and give interval notation for the solution to inequalities with absolute values. When an inequality has an absolute value we will

More information

Addition Methods. Methods Jottings Expanded Compact Examples 8 + 7 = 15

Addition Methods. Methods Jottings Expanded Compact Examples 8 + 7 = 15 Addition Methods Methods Jottings Expanded Compact Examples 8 + 7 = 15 48 + 36 = 84 or: Write the numbers in columns. Adding the tens first: 47 + 76 110 13 123 Adding the units first: 47 + 76 13 110 123

More information

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

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

More information

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

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

More information

3.3 Addition and Subtraction of Rational Numbers

3.3 Addition and Subtraction of Rational Numbers 3.3 Addition and Subtraction of Rational Numbers In this section we consider addition and subtraction of both fractions and decimals. We start with addition and subtraction of fractions with the same denominator.

More information

Trigonometric Functions and Triangles

Trigonometric Functions and Triangles Trigonometric Functions and Triangles Dr. Philippe B. Laval Kennesaw STate University August 27, 2010 Abstract This handout defines the trigonometric function of angles and discusses the relationship between

More information

Part 1 Expressions, Equations, and Inequalities: Simplifying and Solving

Part 1 Expressions, Equations, and Inequalities: Simplifying and Solving Section 7 Algebraic Manipulations and Solving Part 1 Expressions, Equations, and Inequalities: Simplifying and Solving Before launching into the mathematics, let s take a moment to talk about the words

More information

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

More information

Adding and Subtracting Positive and Negative Numbers

Adding and Subtracting Positive and Negative Numbers Adding and Subtracting Positive and Negative Numbers Absolute Value For any real number, the distance from zero on the number line is the absolute value of the number. The absolute value of any real number

More information

Figure 1. A typical Laboratory Thermometer graduated in C.

Figure 1. A typical Laboratory Thermometer graduated in C. SIGNIFICANT FIGURES, EXPONENTS, AND SCIENTIFIC NOTATION 2004, 1990 by David A. Katz. All rights reserved. Permission for classroom use as long as the original copyright is included. 1. SIGNIFICANT FIGURES

More information

MACHINE INSTRUCTIONS AND PROGRAMS

MACHINE INSTRUCTIONS AND PROGRAMS CHAPTER 2 MACHINE INSTRUCTIONS AND PROGRAMS CHAPTER OBJECTIVES In this chapter you will learn about: Machine instructions and program execution, including branching and subroutine call and return operations

More information

1 1 0 1 0 1 0 1 ( 214 (represen ed by flipping) - 256 (magnitude = -42) 1 1 0 1 0 1 1 0 = -128 + 64 + 16 + 4 + 1 = -42 (flip the bits and add 1)

1 1 0 1 0 1 0 1 ( 214 (represen ed by flipping) - 256 (magnitude = -42) 1 1 0 1 0 1 1 0 = -128 + 64 + 16 + 4 + 1 = -42 (flip the bits and add 1) 1. Express 42 (decimal) in 8-bit binary 128 64 32 16 8 4 2 1 0 0 1 0 1 0 1 0 = 32 + 8 + 2 = 42 NOTE: This document is not officially endorsed by the Department of Informatics, or the lecturers responsible

More information

Properties of sequences Since a sequence is a special kind of function it has analogous properties to functions:

Properties of sequences Since a sequence is a special kind of function it has analogous properties to functions: Sequences and Series A sequence is a special kind of function whose domain is N - the set of natural numbers. The range of a sequence is the collection of terms that make up the sequence. Just as the word

More information

Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6

Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6 Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6 Number Systems No course on programming would be complete without a discussion of the Hexadecimal (Hex) number

More information

A Little Set Theory (Never Hurt Anybody)

A Little Set Theory (Never Hurt Anybody) A Little Set Theory (Never Hurt Anybody) Matthew Saltzman Department of Mathematical Sciences Clemson University Draft: August 21, 2013 1 Introduction The fundamental ideas of set theory and the algebra

More information

Grade 6 Math Circles. Binary and Beyond

Grade 6 Math Circles. Binary and Beyond Faculty of Mathematics Waterloo, Ontario N2L 3G1 The Decimal System Grade 6 Math Circles October 15/16, 2013 Binary and Beyond The cool reality is that we learn to count in only one of many possible number

More information