Garry's Mod Wiki

math.Truncate

  number math.Truncate( number num, number digits = 0 )

Description

Trim unwanted decimal places.

Arguments

1 number num
The number to truncate
2 number digits = 0
The amount of digits to keep after the point.

Returns

1 number
The result.

Example

Demonstrates the use of this function.

local num = 54.59874 print( math.Truncate( num, 2 ) ) -- 54.59 print( math.Round( num, 2 ) ) -- 54.6
Output:
54.59 54.6