Garry's Mod Wiki

math.pi

Description

A variable containing the mathematical constant pi. (3.1415926535898)

See also: Trigonometry

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. See second example below.

Returns

1 number
The mathematical constant, Pi.

Example

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

Example

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