The Mathematics Driving License for Computer Science- CS10410 Approximating Numbers, Number Systems and 2 s Complement by Nitin Naik
Approximating Numbers There are two kinds of numbers: Exact Number and Approximate Number. Exact Numbers arise from counting. Approximate Numbers arise from measurement or calculation. We can never perform a completely accurate measurement with a ruler, tape measure or thermometer. There is always some inaccuracy involved.
Approximating Numbers.. Sometimes instead of giving exact numbers, it is preferable to give approximations. This is especially when if we want to be vague about the numbers we are reporting! Certain numbers simply cannot be written exactly in decimal form. Many fractions and all irrational numbers fall into this category. For example the fraction 1/3 is approximately but not exactly equal to 0.333 and the irrational number 3 is approximately but not exactly equal to 1.73.
Examples
Significant Digits or Figures All the digits in the number are significant digits (also known as significant figures) except if the digit is a zero that is used just to locate the decimal point then it is not significant. This means a digit which is 0 is significant if it is not a place holder. In an approximate number the leftmost digit is said to be the Most Significant Digit and the rightmost digit is the Least Significant Digit. Significant digits give an indication of the accuracy of a number.
Significant Digits or Figures.. Example-1: The approximate number is 5.619 It has 4 significant digits. The digit 5 is the Most Significant Digit (MSD). The digit 9 is the Least Significant Digit (LSD).
Significant Digits or Figures..
Accuracy and Precision Accuracy The accuracy of an approximate number is given by the number of significant digits in it. Precision The precision of an approximate number is given by the position of the rightmost significant digit (decimal position of the last significant digit).
Example Comparing the two numbers 0.051 and 4.673 Accuracy Here 4.673 is more accurate because it has four significant digits, where 0.051 only has two. Precision The two numbers have the same precision, as the last significant digit is in the thousandths position for both.
Rounding Numbers When rounding number to a certain place value then all digits to the right of that place are dropped.
Rounding Down If the first dropped digit in number is 0, 1, 2, 3, or 4 then the least significant digit kept is not changed. This is called rounding down.
Rounding Up If the first dropped digit in number is 5, 6, 7, 8 or 9 then the least significant digit kept is increased by 1. This is called rounding up.
Rounding Examples Example-1: 70.531 The number 70.531 rounded to four significant digits is 70.53 The number 70.531 rounded to three significant digits is 70.5 The number 70.531 rounded to two significant digits is 71
Rounding Examples.. Example-2:Some examples of rounding to 2 decimal places (the dropped digits are shown in red):
Rounding Examples.. Example-3:Some examples of rounding to 3 significant figures (the dropped digits are shown in red):
Operations with Approximate Numbers When adding or subtracting approximate numbers, the result should have the precision of the least precise number. Example-1: When adding 2.3, 5.704 and 12.67, our final answer should be correct to one decimal place. 2.3 + 5.704 + 12.67 = 20.674 20.7 (the symbol for "is approximately equal to")
Operations with Approximate Numbers.. When multiplying or dividing approximate numbers, the result should have the accuracy of the least accurate number. Example-2: When multiplying 3.564 and 2.37, our final answer should have three significant digits. 3.564 2.37 = 8.44668 8.45
Operations with Approximate Numbers.. When finding the square root of a number, the result has the same accuracy as the number. Example-3: 22.97 should be written correct to 4 significant digits: 22.97 4.793 (same accuracy)
Number System It is the set of characters and mathematical rules that are used to represent a number.
Decimal Number System The Decimal number system consists of ten digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 and afterwards the numbers are formed by grouping these digits together and known as Base-10 system.
Decimal Number System..
Binary Number System The Binary number system is similar to the decimal system except binary system contains only two digits- 0 and 1 and called Base-2 system.
Octal Number System The Octal number system consists of eight digits 0, 1, 2, 3, 4, 5, 6, and 7 and called Base-8 system. Octal was used extensively in early mainframe computer systems, but has become less popular in favor of binary and hexadecimal today.
Hexadecimal Number System The Hexadecimal number system uses 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F and thus called Base-16 system. Hexadecimal numbers are easy to convert to the computer's internal binary code and are more compact than binary numbers.
Hexadecimal Number System.. Decimal Values of Hex Alphabets
Number System Conversions Actually we commonly understand only Decimal number system so the number written in other three number systems must be converted to know the actual decimal value of that number. Number system conversions are also required for many computer applications and operations. Here we will study the most important number system conversions.
Binary to Decimal Conversion For this conversion remember these values: 2 0 =1 2 0 =1/1=1 2 1 =2 2-1 =1/2=0.5 2 2 =4 2-2 =1/4=0.25 2 3 =8 2-3 =1/8=0.125 2 4 =16 2-4 =1/16=0.0625 2 5 =32 2-5 =1/32=0.03125 2 6 =64 2-6 =1/64=0.015625 2 7 =128 2-7 =1/128=0.0078125 2 8 =256 2-8 =1/256=0.00390625 2 9 =512 2-9 =1/512=0.001953125 2 10 =1024 2-10 =1/1024=0.0009765625
Binary to Decimal Conversion (Integer Part)
Binary to Decimal Conversion (Integer Part)..
Binary to Decimal Conversion (Real Part)
Octal to Decimal Conversion For this conversion remember these values:
Octal to Decimal Conversion..
Hexadecimal to Decimal Conversion For this conversion remember these values:
Hexadecimal to Decimal Conversion..
Binary-to-Octal or Octal-to-Binary Three binary digits are equivalent to one octal digit, as shown in the table below:
Binary-to-Octal To convert from binary to octal, divide the binary number into groups of 3 digits starting on the right of the binary number. If the leftmost group has less than 3 bits, put in the necessary number of leading zeroes on the left. For each group of three bits, write the corresponding single octal digit.
Binary-to-Octal..
Binary-to-Octal..
Octal-to-Binary To convert from octal to binary, write the corresponding group of three binary digits for each octal digit.
Octal-to-Binary..
Binary-to-Hexadecimal or Hexadecimal-to-Binary Four binary digits are equivalent to one hexadecimal digit, as shown in the given table.
Binary-to-Hexadecimal To convert from binary to hexadecimal, divide the binary number into groups of 4 digits starting on the right of the binary number. If the leftmost group has less than 4 bits, put in the necessary number of leading zeroes on the left. For each group of four bits, write the corresponding single hex digit.
Binary-to-Hexadecimal..
Binary-to-Hexadecimal..
Hexadecimal-to-Binary To convert from hexadecimal to binary, write the corresponding group of four binary digits for each hex digit.
Hexadecimal-to-Binary..
Two's Complement Notation Property Two's complement number representation is used for signed numbers on most modern computers. Two's complement representation allows the use of binary arithmetic operations on signed integers, yielding the correct 2's complement results.
Two's Complement Notation.. Positive Numbers Positive 2's complement numbers are represented as the simple binary. Negative Numbers Negative 2's complement numbers are represented as the binary number that when added to a positive number of the same magnitude equals zero. Sign Bit The most significant bit is called the sign bit. Operations This notation allows a computer to add and subtract numbers using the same operations (thus we do not need to implement adders and subtractors).
One's Complement In one's complement, positive numbers are represented as usual in regular binary. However, negative numbers are represented differently. To negate a number, replace all zeros with ones, and ones with zeros - flip the bits. Example: 12 = 0 0 0 0 1 1 0 0 and -12 = 1 1 1 1 0 0 1 1 (1 s Complement) As in signed magnitude, the leftmost bit indicates the sign (1 is negative, 0 is positive). To compute the value of a negative number, flip the bits and translate as before.
Two's Complement Example: 12 = 0 0 0 0 1 1 0 0 1 1 1 1 0 0 1 1 (1 s Complement) + 1 --------------------------------- -12 = 1 1 1 1 0 1 0 0 (2 s Complement)
References www.gnosislearning.com/_document/approximating+ Numbers.pdf http://www.intmath.com/numbers/5-approximatenumbers.php http://mathonweb.com/help_ebook/html/numbers_8. htm http://www.thevbprogrammer.com/ch04/number%20 Systems%20Tutorial.pdf http://academic.evergreen.edu/projects/biophysics/te chnotes/program/2s_comp.htm http://www.math.grin.edu/~rebelsky/courses/152/97f /Readings/student-binary#one
Thank You