pow — Raise a number to a power


Float.pow(base, power)

base: Floating point

power: Floating point


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.


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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.