ToFloatPower (Float function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (match syntax diagram to template; fix tags and links)
Line 1: Line 1:
{{Template:Float:ToFloatPower subtitle}}
{{Template:Float:ToFloatPower subtitle}}


This [[Intrinsic classes|intrinsic]] function returns a number that is the method object value
The <var>ToFloatPower</var> <var>[[Intrinsic classes|intrinsic]]</var> function returns a number that is the method object value [http://en.wikipedia.org/wiki/Raised_to_the_power "raised to the float power"] specified by the method argument.
[http://en.wikipedia.org/wiki/Raised_to_the_power raised to the float power] specified by the method argument.


Available as of version 7.3 of the <var class=product>Sirius Mods</var>, the <var>ToFloatPower</var> function is
an object-oriented version of the $RXPR function.
==Syntax==
==Syntax==
{{Template:Float:ToFloatPower syntax}}
{{Template:Float:ToFloatPower syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%value</th>
<tr><th>%number</th>
<td>A numeric variable to contain the method result. </td></tr>
<td>A numeric variable to contain the method result. </td></tr>
<tr><th>number</th>
<tr><th>float</th>
<td>A <var>Float</var> value. </td></tr>
<td>A <var>Float</var> value. </td></tr>
<tr><th>exponent</th>
<tr><th>exponent</th>
<td>A <var>Float</var> value.</td></tr>
<td>A <var>Float</var> value.</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
*If ''number'' is equal to 0, and ''exponent'' is less than or equal to 0, the request is cancelled.
<ul><li>If <var class="term>float</var> is equal to 0, and <var class="term>float</var> is less than or equal to 0, the request is cancelled.
*If ''number'' is less than 0, and ''exponent'' is not 0, the request is cancelled. This is so because, unlike the [[Intrinsic ToIntegerPower Function|ToIntegerPower function]], the computation algorithm involves the log of ''number''.
<li>If <var class="term>float</var> is less than 0, and <var class="term>float</var> is not 0, the request is cancelled. This is so because, unlike <var>[[ToIntegerPower_(Float_function)|ToIntegerPower]]</var>, the computation algorithm involves the log of <var class="term>float</var>.
*<var>ToFloatPower</var> uses good-fit techniques that sometimes produce slightly different results from ToIntegerPower with the same inputs.
<li><var>ToFloatPower</var> uses good-fit techniques that sometimes produce slightly different results from ToIntegerPower with the same inputs.
<li><var>ToFloatPower</var> is available as of <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.3.</ul>
 
==Examples==
==Examples==
For example:
<ol><li>For example:
<p class="code">b
<p class="code">begin
[[PrintText statement|printText]] {~} = {3:toFloatPower(6)}
  [[PrintText statement|printText]] {~} = {3:toFloatPower(6)}
printText {~} = {3:toIntegerPower(6)}
  printText {~} = {3:toIntegerPower(6)}
printText {~} = {10:toFloatPower(7)}
  printText {~} = {10:toFloatPower(7)}
printText {~} = {10:toIntegerPower(7)}
  printText {~} = {10:toIntegerPower(7)}
end
end
</p>
</p>
displays
displays
<p class="code">3:to<var>Float</var>Power(6) = 728.999999999999
<p class="output">3:toFloatPower(6) = 728.999999999999
3:toIntegerPower(6) = 729
3:toIntegerPower(6) = 729
10:to<var>Float</var>Power(7) = 9999999.99999997
10:toFloatPower(7) = 9999999.99999997
10:toIntegerPower(7) = 10000000
10:toIntegerPower(7) = 10000000
</p>
</p>
Consequently, you should generally use ToIntegerPower unless you really are working with non-integer powers.
Consequently, you should generally use <var>[[ToIntegerPower_(Float_function)|ToIntegerPower]]</var>unless you really are working with non-integer powers.</ol>


==See also==
==See also==
<ul><li><var>ToFloatPower</var> is an object-oriented version of the <var>[[$RXPR]]</var> function.</ul>
{{Template:Float:ToFloatPower footer}}
{{Template:Float:ToFloatPower footer}}

Revision as of 06:04, 4 February 2011

Raise number to a floating point power (Float class)


The ToFloatPower intrinsic function returns a number that is the method object value "raised to the float power" specified by the method argument.

Syntax

%number = float:ToFloatPower( exponent)

Syntax terms

%number A numeric variable to contain the method result.
float A Float value.
exponent A Float value.

Usage notes

  • If float is equal to 0, and float is less than or equal to 0, the request is cancelled.
  • If float is less than 0, and float is not 0, the request is cancelled. This is so because, unlike ToIntegerPower, the computation algorithm involves the log of float.
  • ToFloatPower uses good-fit techniques that sometimes produce slightly different results from ToIntegerPower with the same inputs.
  • ToFloatPower is available as of "Sirius Mods" Version 7.3.

Examples

  1. For example:

    begin printText {~} = {3:toFloatPower(6)} printText {~} = {3:toIntegerPower(6)} printText {~} = {10:toFloatPower(7)} printText {~} = {10:toIntegerPower(7)} end

    displays

    3:toFloatPower(6) = 728.999999999999 3:toIntegerPower(6) = 729 10:toFloatPower(7) = 9999999.99999997 10:toIntegerPower(7) = 10000000

    Consequently, you should generally use ToIntegerPowerunless you really are working with non-integer powers.

See also

  • ToFloatPower is an object-oriented version of the $RXPR function.