Learn Pascal
1F - Standard Functions

Pascal has several standard mathematical functions that you can utilize. For example, to find the value of sin of pi radians,
     value := sin (3.1415926535897932);
Note that the sin function operates on angular measure stated in radians. This is true of all the trigonometric functions. If everything goes well, value should become 0.

Functions are called by using the function name followed by the argument(s) in parentheses.

Standard Pascal functions are:

Function Name Description Argument type Return type
absabsolute valuereal or integer same as argument type
arctanarctan in radiansreal or integer real
coscosine of a radian measure real or integerreal
expe to the given power real or integerreal
lnnatural logarithm real or integerreal
roundround to nearest integer realinteger
sinsin of a radian measure real or integerreal
sqrsquare (power 2) real or integersame as argument type
sqrtsquare root (power 1/2) real or integerreal
trunctruncate (round down) real or integerinteger

For ordinal data types (integer or char), which have a distinct predecessor and successor, you can use these functions:

Function Description Argument type Return type
chrcharacter with given ASCII value integerchar
ordordinal value integer or charinteger
predpredecessor integer or charsame as argument type
succsuccessor integer or charsame as argument type

Real is not an ordinal data type! That's because it has no distinct successor or predecessor. What is the successor of 56.0? It could be
     56.1 56.01 56.001 56.0001 56.00001 56.000001

However, for an integer 56, there is a distinct predecessor -- 55 -- and a distinct successor -- 57.

The same is true of characters:

     'b'
     Successor:   'c'
     Predecessor: 'a'

Previous lesson

Next lesson

Contents

Index

e-mail me


taoyue@mit.edu
Copyright © 1997-2001 Tao Yue. All rights reserved.