Garry's Mod Wiki

math.pi

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 effective infinity.

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

Special Pages


Wikis

?

Render Time: 65ms

DB GetPage 43
Generate Html 3
SaveChanges (1) 9
Render Body 0
Render Sidebar 7