O'Reilly logo

Learning WML, and WMLScript by Martin Frost

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

pow — Raise a number to a power

Usage

Float.pow(base, power)

base: Floating point

power: Floating point

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required