PI: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE: _PI}} The _PI function returns '''π''' as a _FLOAT value with an optional multiplier parameter. {{PageSyntax}} : {{Parameter|circumference}} = _PI[({{Parameter|multiplier}})] {{Parameters}} * Optional {{Parameter|multiplier}} (''2 * radius'' in above syntax) allows multiplication of the π value. {{PageDescription}} * Function can be used in to supply π or multiples in a program. * Accuracy is determined by the return variable type...")
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 4: Line 4:


{{PageSyntax}}
{{PageSyntax}}
: {{Parameter|circumference}} = [[_PI]][({{Parameter|multiplier}})]  
: {{Parameter|circumference}} = [[_PI]][({{Parameter|multiplier}})]




{{Parameters}}
{{PageParameters}}
* Optional {{Parameter|multiplier}} (''2 * radius'' in above syntax) allows multiplication of the π value.
* Optional {{Parameter|multiplier}} (''2 * radius'' in above syntax) allows multiplication of the π value.


Line 22: Line 22:
circlearea = {{Cl|_PI}}(radius ^ 2)
circlearea = {{Cl|_PI}}(radius ^ 2)
PRINT circlearea
PRINT circlearea
{{CodeEnd}}  
{{CodeEnd}}
{{OutputStart}} 78.53982
{{OutputStart}} 78.53982
{{OutputEnd}}
{{OutputEnd}}
Line 29: Line 29:
{{PageSeeAlso}}
{{PageSeeAlso}}
* [[_ATAN2]], [[TAN]]
* [[_ATAN2]], [[TAN]]
* [[ATN]] {{text|(arctangent)}}
* [[ATN]]
* [[SIN]], [[COS]]
* [[SIN]], [[COS]]




{{PageNavigation}}
{{PageNavigation}}

Latest revision as of 21:24, 2 February 2023

The _PI function returns π as a _FLOAT value with an optional multiplier parameter.


Syntax

circumference = _PI[(multiplier)]


Parameters

  • Optional multiplier (2 * radius in above syntax) allows multiplication of the π value.


Description

  • Function can be used in to supply π or multiples in a program.
  • Accuracy is determined by the return variable type AS SINGLE, DOUBLE or _FLOAT.
  • The π value can also be derived using 4 * ATN(1) for a SINGLE value.


Examples

Example: Calculating the area of a circle using a SINGLE variable in this case.

radius = 5
circlearea = _PI(radius ^ 2)
PRINT circlearea
 78.53982


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link