Built-in functions: math_max()

The function math_max() estimates the largest value.

Declaration

Form 1:

int32  math_max( int32  aValue1, int32  aValue2, ... )

uint32 math_max( uint32 aValue1, uint32 aValue2, ... )

int64  math_max( int64  aValue1, int64  aValue2, ... )

uint64 math_max( uint64 aValue1, uint64 aValue2, ... )

float  math_max( float  aValue1, float  aValue2, ... )

char   math_max( char   aValue1, char   aValue2, ... )

Form 2:

point math_max( point aValue1, point aValue2, ... )

rect  math_max( rect  aValue1, rect  aValue2, ... )

color math_max( color aValue1, color aValue2, ... )

Parameters

aValue1, aValue2, ...

The values to evaluate and estimate the maximum.

Discussion

The function math_max() evaluates the values passed in its parameters and returns the largest one. In its first form the function simply compares the passed numbers and selects the largest one. For example:

var float max1 = math_max( 1.0, 5.7, -9.7, -13.9 ); // max1 = 5.7 var char max2 = math_max( 'A', 'F', 'Z', 'G' ); // max2 = 'Z'

The second form accepts parameters of more complex data types containing multiple components each. For example, an operand of type point contains the components x and y. In this case the function compares the passed values component-wise selecting individually from each component the largest one. Similarly, with color operands, the function selects the largest values for the red, green, blue and alpha color components. For example:

var point max1 = math_max( <1,8>, <5,2>, <-9,-10>, <-13,12> ); // max1 = <5,12> var color max2 = math_max( #12345678, #AA121122, #4523CCFF ); // max2 = #AA34CCFF

All forms of the function math_max() expect at least two parameters. The given parameters must be of the same data type with the first parameter determining also the resulting data type of the entire operation.