Garry's Mod Wiki

math.max

  number math.max( ... )

Description

Returns the largest value of all arguments.

Arguments

1 vararg numbers
Numbers to get the largest from

Returns

1 number
The largest number

Example

Get the largest number of a group.

print( math.max( 464, 654698468, 1, 3, 2 ) )
Output:
654698468

Example

Prevent a value from falling under a certain minimum. A one-sided version of math.Clamp.

local minimumValue = 5 function lowClamp(num) return math.max( minimumValue, num ) end print( lowClamp( 0.1 ) ) print( lowClamp( -6 ) ) print( lowClamp( 5 ) ) print( lowClamp( 8 ) ) print( lowClamp( 24 ) )
Output:
5 5 5 8 24