19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

36 <strong>Computer</strong> <strong>Programming</strong> <strong>Concepts</strong> <strong>and</strong> <strong>Visual</strong> <strong>Basic</strong><br />

■ SCIENTIFIC NOTATION<br />

Let us review powers of 10 <strong>and</strong> scientific notation. Our method of decimal notation is based<br />

on a systematic use of exponents.<br />

10 1 = 10 10 –1 = 1/10 = .1<br />

10 2 = 100 10 –2 = .01<br />

10 3 = 1000 10 –3 = .001<br />

.<br />

.<br />

.<br />

10 n = 1000...0 10 –n = .001...01<br />

n zeros n digits<br />

Scientific notation provides a convenient way of writing numbers by using powers of 10<br />

to st<strong>and</strong> for zeros. Numbers are written in the form b � 10 r , where b is a number from 1 up<br />

to (but not including) 10, <strong>and</strong> r is an integer. For example, it is much more convenient to<br />

write the diameter of the sun (1,400,000,000 meters) in scientific notation: 1.4 � 10 9 meters.<br />

Similarly, rather than write .0000003 meters for the diameter of a bacterium, it is simpler to<br />

write 3 � 10–7 meters.<br />

Any acceptable number can be entered into the computer in either st<strong>and</strong>ard or scientific<br />

notation. The form in which <strong>Visual</strong> <strong>Basic</strong> displays a number depends on many factors, with<br />

size being an important consideration. In <strong>Visual</strong> <strong>Basic</strong>, b � 10 r is usually written as bEr. (The<br />

letter E is an abbreviation for exponent.) The following forms of the numbers just mentioned<br />

are equivalent.<br />

1.4 * 10^9 1.4E+09 1 4E+9 1.4E9 1400000000<br />

3 * 10^–7 3E–07 3E–7 .0000003<br />

The computer displays r as a two-digit number, preceded by a plus sign if r is positive <strong>and</strong> a<br />

minus sign if r is negative.<br />

EXAMPLE 2<br />

The following program illustrates scientific notation. The computer’s choice of whether to display a number<br />

in scientific or st<strong>and</strong>ard form depends on the magnitude of the number.<br />

Private Sub cmdCompute_Click()<br />

picResults.Cls<br />

picResults.Print 1.2 * 10 ^ 34<br />

picResults.Print 1.2 * 10 ^ 8<br />

picResults.Print 1.2 * 10 ^ 3<br />

picResults.Print 10 ^ -20<br />

picResults.Print 10 ^ -2<br />

End Sub<br />

[Run <strong>and</strong> then click the comm<strong>and</strong> button.]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!