Garry's Mod Wiki

math.Truncate

math.Truncate

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

Description

Rounds towards zero.

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

Special Pages


Wikis

?

Render Time: 88ms

DB GetPage 48
Generate Html 4
SaveChanges (1) 27
Render Body 0
Render Sidebar 6