Garry's Mod Wiki

math.pi

Not a function

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

See also: Trigonometry

Example

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.

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

Page Links


Special Pages


Wikis

?

Render Time: 289ms

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