power: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Irisiflimsi (talk | contribs) No edit summary |
||
Line 3: | Line 3: | ||
|version=1.3b36 | |version=1.3b36 | ||
|description= | |description= | ||
Returns a {{code|number}} raised to the power of {{code|2}}, or raised to a specific ''exponent''. | Returns a {{code|number}} raised to the power of {{code|2}}, or raised to a specific ''exponent''. Both versions use integer arithmetic during calculations, which does not always become apparent in the results, which may have fractional parts. Use [[math.pow]] when non-integer precision is needed. | ||
|usage= | |usage= |
Latest revision as of 10:29, 28 December 2024
power() Function
• Introduced in version 1.3b36
Returns a
number
raised to the power of 2
, or raised to a specific exponent. Both versions use integer arithmetic during calculations, which does not always become apparent in the results, which may have fractional parts. Use math.pow when non-integer precision is needed.Usage
power(num)
power(num, exp)
pow(num)
pow(num, exp)
Parameters
num
- the base number used to perform the operation.exp
- the exponent used in the operation.
Examples
Example 1: Use
Returns:
power()
to raise 5
to the power of 2
:
[r: power(5)]
Returns: 25
Example 2: Use pow()
to raise 5
to the power of 3
:
[r: pow(5, 3)]
125