Name
pow — Raise a number to a power
Usage
Float.pow(base, power)
: Floating pointbase
: Floating pointpower
Description
Returns the result of raising base
to the
power power
. This result may be
approximate with some WMLScript interpreters.
There are two special restrictions that come from mathematical
properties of raising numbers to powers: if
base
is negative,
power
must be an integer, and if
base
is zero,
power
must not be negative. If either of
these conditions isn’t met, returns invalid
.
Examples
Float.pow(3.0, 2.0)
returns floating-point 9.0
Float.pow(9.0, 0.5)
returns floating-point 3.0
Float.pow(8.0, 1/3)
returns floating-point 2.0
Float.pow(-2.0, 0.0)
returns floating-point 1.0
Float.pow(-2.0, 4.0)
returns floating-point 16.0
Float.pow(-2.0, 5.0)
returns floating-point -32.0
Float.pow(-2.0, -1.0)
returns floating-point -0.5
Float.pow(-2.0, 0.5)
returns invalid
Float.pow(0.0, 1.7)
returns floating-point 0.0
Float.pow(0.0, 0.0)
returns floating-point 1.0
Float.pow(0.0, -1.0)
returns invalid
Float.pow(1e20, 2.0)
returns invalid
Get Learning WML, and WMLScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.