Revision Difference
math.pi#528429
<cat>libraryfunc</cat>
# Not a function
This is NOT a function, it's a variable containing the mathematical constant pi. (`3.1415926535898`)
See also: <page>Trigonometry</page>
<example>
<code>
print( math.sin( math.pi ) )
print( math.cos( math.pi ) )
</code>⤶
<output>⤶
-1⤶
</output>⤶
</example>⤶
⤶
# 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>⤶
<description>⤶
sin(π) = 0, but because floating point precision is not unlimited it cannot be calculated as exactly 0.⤶
</description>⤶
<code>⤶
print( math.sin( math.pi ), math.sin( math.pi ) == 0 )⤶
</code>
<output>
1.2246467991474e-16⤶
1.2246467991474e-16 false⤶
</output>
</example>