Power
What is it?
The exponent operator (^) we discussed earlier in this guide can be represented instead by a simple function, which accepts two arguments – a base and an exponent.
What is the Syntax?
The Power function’s syntax is as follows:
Power( Base, Exponent );
Why might I want to use this?
As with the Sum function, using the Power function in place of the exponent operator helps to keep your code more readable without having to use too many sets of parentheses.
So instead of the following:
TotalArea := ( ( Square1Length ^ 2 ) + ( Square2Length ^ 2 ) );
You could use the Power function to write this:
TotalArea := Power( Square1Length, 2 ) + Power( Square2Length, 2 );
Both expressions produce the same result, but using the second, particularly in larger expressions, makes your code more readable.
<< Previous: Sum | Next: Modulus (Mod) >>