power: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page Power to power: Converting page titles to lowercase)
No edit summary
 
Line 6: Line 6:


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
power(num)
power(num)
</source>
</syntaxhighlight>
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
power(num, exp)
power(num, exp)
</source>
</syntaxhighlight>
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
pow(num)
pow(num)
</source>
</syntaxhighlight>
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
pow(num, exp)
pow(num, exp)
</source>
</syntaxhighlight>
'''Parameters'''
'''Parameters'''
* {{code|num}} - the ''base number'' used to perform the operation.
* {{code|num}} - the ''base number'' used to perform the operation.
Line 24: Line 24:
|examples=
|examples=
'''Example 1:''' Use {{code|power()}} to raise {{code|5}} to the power of {{code|2}}:
'''Example 1:''' Use {{code|power()}} to raise {{code|5}} to the power of {{code|2}}:
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[r: power(5)]
[r: power(5)]
</source>
</syntaxhighlight>
'''Returns:''' {{code|25}}
'''Returns:''' {{code|25}}


'''Example 2:''' Use {{code|pow()}} to raise {{code|5}} to the power of {{code|3}}:
'''Example 2:''' Use {{code|pow()}} to raise {{code|5}} to the power of {{code|3}}:
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[r: pow(5, 3)]
[r: pow(5, 3)]
</source>
</syntaxhighlight>
'''Returns:''' {{code|125}}
'''Returns:''' {{code|125}}



Latest revision as of 22:34, 14 March 2023

power() Function

Introduced in version 1.3b36
Returns a number raised to the power of 2, or raised to a specific exponent.

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 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)]
Returns: 125

See Also