Garry's Mod Wiki

Garry's Mod Wiki

  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

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...