Presentation is loading. Please wait.

Presentation is loading. Please wait.

Decimal Numbers Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Copyright © 2007 by Douglas Wilhelm Harder.

Similar presentations


Presentation on theme: "Decimal Numbers Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Copyright © 2007 by Douglas Wilhelm Harder."— Presentation transcript:

1 Decimal Numbers Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Copyright © 2007 by Douglas Wilhelm Harder. All rights reserved. ECE 204 Numerical Methods for Computer Engineers

2 Decimal Numbers This topic is a quick review of decimal numbers, both integers and real numbers –standard notation –scientific notation –addition –multiplication

3 Decimal Numbers We represent an integer as a sequence of decimal digits: d n d n – 1 d n – 2 · · · d 2 d 1 d 0 where d n  0 This represents the number

4 Decimal Numbers For example, 214932 represents 200000 + 10000 + 4000 + 900 + 30 + 2 or 2·10 5 + 1·10 4 + 4·10 3 + 9·10 2 + 3·10 1 + 2·10 0

5 Decimal Numbers The sequence of integers is 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,..., 17, 18, 19, 20, 21,... where we increment the next decimal digit to the left whenever we add one to a 9 Note that there is nothing special about “ten”, the base of our number system Our decimal system uses ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

6 Decimal Numbers We represent a real number as a sequence of decimal digits: d n d n – 1 · · · d 1 d 0. d –1 d –2 d –3 · · · where d n  0, and n is any integer This represents the number

7 Decimal Numbers For example,  = 3.14159265··· represents 3 + 0.1 + 0.04 + 0.001 + 0.0005 + 0.00009 + ··· or 3·10 0 + 1·10 –1 + 4·10 –2 + 1·10 –3 + 4·10 –4 + 9·10 –5 + ···

8 Decimal Numbers We cannot store an infinite number of decimal digits, and therefore, we approximate real numbers using a finite number of decimal digits: d n d n – 1 · · · d 0. d –1 · · · d m where d n  0, n is any integer and m  n This represents the number

9 Decimal Numbers For example, 214.932 represents 200 + 10 + 4 + 0.9 + 0.03 + 0.002 or 2·10 2 + 1·10 1 + 4·10 0 + 9·10 –1 + 3·10 –1 + 2·10 –2 Also, 3.14 represents 3 + 0.1 + 0.04 = 3·10 0 + 1·10 –1 + 4·10 –2

10 Decimal Numbers These formats can be inconvenient if n and m are either both very large or both very small: 52320000000000. 0.00000000000005232 and thus it is common to use scientific notation to represent real numbers or their approximations

11 Decimal Numbers Any real number can be written as d 0.d -1 d -2 d -3 · · · d –m  10 n where d 0  0 This is often more conveniently written as d 0.d -1 d -2 d -3 ···d –m en where n is the exponent, e denotes exponent, and the digits d 0.d -1 d -2 d -3 ···d are the mantissa

12 Decimal Numbers For example: –214.932 may be written as 2.14932  10 2 or 2.14932e2 –3.14 may be written as 3.14  10 0 or 3.14e0 –52320000000000. may be written as 5.232  10 13 or 5.232e13 –0.00000000000005232 may be written as 5.232  10 –14 or 5.232e-14

13 Decimal Numbers To add two decimal numbers: –line up the decimal points, add the columns, carrying 1 to next column if the sum is greater than 9 : –for example, add 3259.3 = 3.2593e3 and 5.3549 = 5.3549e0 yielding 3.2646549e3

14 Decimal Numbers Multiplication of numbers in scientific notation is similar, multiply the mantissa and add the exponents –for example, multiply 27000 = 2.7e4 and 0.32 = 3.2e-1 yielding 8.64e3 where 3 = 4 + –1

15 Decimal Numbers In both addition and multiplication, an adjustment may have to be made to keep the numbers in scientific notation For example, 9.25e0 + 5.23e0 = 14.48e0 = 1.448e1

16 Decimal Numbers The justification for these apparently obvious examples is that we will next be working with binary numbers –computers can only store binary numbers –the representation is slightly different, but the operations are the same

17 Usage Notes These slides are made publicly available on the web for anyone to use If you choose to use them, or a part thereof, for a course at another institution, I ask only three things: –that you inform me that you are using the slides, –that you acknowledge my work, and –that you alert me of any mistakes which I made or changes which you make, and allow me the option of incorporating such changes (with an acknowledgment) in my set of slides Sincerely, Douglas Wilhelm Harder, MMath dwharder@alumni.uwaterloo.ca


Download ppt "Decimal Numbers Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Copyright © 2007 by Douglas Wilhelm Harder."

Similar presentations


Ads by Google