math.max

From Garry's Mod
Jump to: navigation, search
 math.max( )

Contents

Description

Returns the largest value of all arguments.

Arguments

vararg numbers

Numbers to get the largest from

Returns

number

The largest number

Examples

Example

Get the largest number of a group.

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

Output:

654698468

Examples

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
Personal tools
Navigation