Garry's Mod Wiki

math.max

number math.max( vararg numbers )

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

Page Links


Special Pages


Wikis

?

Render Time: 33ms

DB GetPage 4
Generate Html 6
SaveChanges (1) 8
Render Body 0
Render Sidebar 13