ToFloatPower (Float function): Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (1 revision) |
||
Line 4: | Line 4: | ||
[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 ToFloatPower function is | 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. | an object-oriented version of the $RXPR function. | ||
==Syntax== | ==Syntax== | ||
Line 20: | Line 20: | ||
*If ''number'' is equal to 0, and ''exponent'' is less than or equal to 0, the request is cancelled. | *If ''number'' is equal to 0, and ''exponent'' 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''. | *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''. | ||
*ToFloatPower uses good-fit techniques that sometimes produce slightly different results from ToIntegerPower with the same inputs. | *<var>ToFloatPower</var> uses good-fit techniques that sometimes produce slightly different results from ToIntegerPower with the same inputs. | ||
==Examples== | ==Examples== | ||
For example: | For example: |
Revision as of 15:32, 19 January 2011
Raise number to a floating point power (Float class)
This intrinsic function returns a number that is the method object value
raised to the float power specified by the method argument.
Available as of version 7.3 of the Sirius Mods, the ToFloatPower function is an object-oriented version of the $RXPR function.
Syntax
%number = float:ToFloatPower( exponent)
Syntax terms
%value | A numeric variable to contain the method result. |
---|---|
number | A Float value. |
exponent | A Float value. |
Usage notes
- If number is equal to 0, and exponent 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 ToIntegerPower function, the computation algorithm involves the log of number.
- ToFloatPower uses good-fit techniques that sometimes produce slightly different results from ToIntegerPower with the same inputs.
Examples
For example:
b 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 ToIntegerPower unless you really are working with non-integer powers.
See also
List of intrinsic Float methods