Pascal: Exponents

The calculation 10 ^ X is not included in the UCSD Pascal definition. The
system intrinsic PWROFTEN ("power of ten") returns 10 ^ X, provided X is an
integer in the range 0..37. (Please refer to page 45 in the Pascal Language
Reference manual.)

The function EXP (in the library unit TRANSCEN) is of the form e ^ X, where X
is a real number. The relationship between 10 ^ X and e ^ X is:

10 ^ X = e ^ (X LN 10) (LN = natural log)

Here is a simple program which illustrates the use of Pascal exponents:

PROGRAM EXPONENT;

USES TRANSCEND;

BEGIN
WRITELN ('10 ^ 3 = ',PWROFTEN(3));
WRITELN ('e ^ 3 = ',EXP(3));
WRITELN ('10 ^ 3 by the conversion = ',EXP(3*LN(10)));
END.

Published Date: Feb 18, 2012