Download presentation
Presentation is loading. Please wait.
Published byMorgan Melton Modified over 6 years ago
1
CPSC 110 - Pascal Brent M. Dingle Texas A&M University Chapter 3
Finishing Chapter 3 CPSC Pascal Brent M. Dingle Texas A&M University Chapter 3
2
Predefined Functions Pascal, like most programming languages, offers a set of predefined functions. Unfortunately not all languages offer the same set of predefined functions. Some functions Pascal offers are: sqrt(x); - returns the square root of x abs(x); - returns the absolute value of x round(x) - rounds x to the nearest integer trunc(x) - truncates x to the nearest integer sqr(x) - returns x squared (i.e. x*x)
3
Natural Logarithm and e
Pascal also offers the predefined functions: ln(x) exp(z) ln(x) returns the natural log of x. aside: natural log is log base e where e is approximately exp(z) returns e raised to the z power
4
ln and exp trick Suppose you wanted to set z = xy.
We know xy = (eln(x))y = ey*(ln(x)). And ey*(ln(x)) = exp(y*ln(x)). So to set z = xy, we would say: z := exp( y * ln(x) );
5
End Predefines and ln and e
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.