Garry's Mod Wiki


Not a function

This is NOT a function, it's a variable containing the mathematical constant pi. (3.1415926535898)

See also: Trigonometry


print( math.cos( math.pi ) )
Output: -1

Floating point precision considerations

It should be noted that due to the nature of floating point numbers, results of calculations with math.pi may not be what you expect.


sin(π) = 0, but because floating point precision is not unlimited it cannot be calculated as exactly 0.

print( math.sin( math.pi ), math.sin( math.pi ) == 0 )
Output: 1.2246467991474e-16 false

Page Links

Special Pages



Render Time: 289ms

DB GetPage 31
Generate Html 2
SaveChanges (1) 236
Render Body 0
Render Sidebar 17