Maximum (Max)
What is it?
The Max function compares two numeric arguments and returns the larger of the two values.
What is the Syntax?
The syntax for the Max function is as follows:
Max( Argument1, Argument2 );
Why might I want to use this?
It may seem excessive to use a function like Max to calculate something you can figure out for yourself, and as such using it to calculate two known, literal numbers is unlikely to benefit you.
On the other hand, the function is useful when you want to compare two dynamic values during the execution of your code, such as the value of a variable or another expression.
In the following example, we want to compare the number of votes received by two election candidates and return the number of votes received by the winner:
WillingVotes := Max( VotesForBill, VotesForJane );
If Bill received 3,050 votes and Jane received 4,870, the value of the Max function will be 4,870. This is then assigned to the WinningVotes variable.
<< Previous: Square Root (Sqrt) | Next: Minimum (Min) >>