* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download d - Electrical and Computer Engineering
Survey
Document related concepts
List of prime numbers wikipedia , lookup
Ethnomathematics wikipedia , lookup
Law of large numbers wikipedia , lookup
History of mathematics wikipedia , lookup
Mathematics of radio engineering wikipedia , lookup
History of mathematical notation wikipedia , lookup
Georg Cantor's first set theory article wikipedia , lookup
Infinitesimal wikipedia , lookup
History of logarithms wikipedia , lookup
Large numbers wikipedia , lookup
Location arithmetic wikipedia , lookup
Real number wikipedia , lookup
Approximations of π wikipedia , lookup
Transcript
ECE 204 Numerical Methods for Computer Engineers Decimal Numbers Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Copyright © 2007 by Douglas Wilhelm Harder. All rights reserved. Decimal Numbers • This topic is a quick review of decimal numbers, both integers and real numbers – standard notation – scientific notation – addition – multiplication Decimal Numbers • We represent an integer as a sequence of decimal digits: dn dn – 1 dn – 2 · · · d2 d1 d0 where dn 0 • This represents the number n d k 0 k 10 k Decimal Numbers • For example, 214932 represents 200000 + 10000 + 4000 + 900 + 30 + 2 or 2·105 + 1·104 + 4·103 + 9·102 + 3·101 + 2·100 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 Decimal Numbers • We represent a real number as a sequence of decimal digits: dn dn – 1 · · · d1 d0 . d–1 d–2 d–3 · · · where dn 0, and n is any integer • This represents the number n d k k 10 k Decimal Numbers • For example, p = 3.14159265··· represents 3 + 0.1 + 0.04 + 0.001 + 0.0005 + 0.00009 + ··· or 3·100 + 1·10–1 + 4·10–2 + 1·10–3 + 4·10–4 + 9·10–5 + ··· Decimal Numbers • We cannot store an infinite number of decimal digits, and therefore, we approximate real numbers using a finite number of decimal digits: dn dn – 1 · · · d0 . d–1 · · · dm where dn 0, n is any integer and m n • This represents the number n k m d k 10 k Decimal Numbers • For example, 214.932 represents 200 + 10 + 4 + 0.9 + 0.03 + 0.002 or 2·102 + 1·101 + 4·100 + 9·10–1 + 3·10–1 + 2·10– 2 • Also, 3.14 represents 3 + 0.1 + 0.04 = 3·100 + 1·10–1 + 4·10–2 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 Decimal Numbers • Any real number can be written as d0.d-1 d-2 d-3 · · · d–m 10n where d0 0 • This is often more conveniently written as d0.d-1d-2d-3···d–men where n is the exponent, e denotes exponent, and the digits d0.d-1d-2d-3···d are the mantissa Decimal Numbers • For example: – 214.932 may be written as 2.14932 102 or 2.14932e2 – 3.14 may be written as 3.14 100 or 3.14e0 – 52320000000000. may be written as 5.232 1013 or 5.232e13 – 0.00000000000005232 may be written as 5.232 10–14 or 5.232e-14 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 1 3259.3 = 3.2593e3 3.2593 and .0053549 5.3549 = 5.3549e0 yielding 3.2646549e3 3.2646549 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 2 .7 3 .2 .54 8.10 8.64 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 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 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 [email protected]