math/max

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m
Line 33: Line 33:
 
print( lowClamp( 8 ) )
 
print( lowClamp( 8 ) )
 
print( lowClamp( 24 ) )
 
print( lowClamp( 24 ) )
|Output=
+
|Output=5, 5, 5, 8, 24
5
+
 
5
+
5
+
8
+
24
+
 
}}
 
}}

Revision as of 14:14, 11 April 2018

 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( 1, 2, 3, 464, 654698468 ) )

Output:

654698468

Examples

Example

Disable a value from falling under a certain amount. Alternative to math.Clamp, a more expensive function.

local minimumValue = 5;

function lowClamp(int)

     return tostring( math.max( minimumValue, int ) )

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