Function: Max
Function: Max

Function: Max

Max ( VALUE1, VALUE2 )

Returns the greater of two values.

Parameters

Parameter Type Description
VALUE1 VALUE The first value.
VALUE2 VALUE The second value.

Returns

VALUE The greater value.

What It Does

This function returns the greater of the two provided values, comparatively. If both values are different types, they are interpreted as the value of the highest type, promotion-wise (if one value is a string, and the other is not, they are compared as strings). The type of the returned value is the same type as the greater value.


	a = max(-2, 2);             // a = 2
	a = max(6, 3.4);            // a = 6
	a = max("apple", "orange");	// a = "orange"
	a = max("apple", "Apple");	// a = "apple"
	a = max(123, "pears");	    // a = "pears"

See Also

Min — Returns the lesser of two values.

Additional Technical Notes

Strings are compared lexicographically, which is character-order (not alphabetical). The sorting is based on the character values, not any kind of locale-based or linguistic significance.

×

Modal Header