18.3. Raising a Numeric Value to the Power of Another Numeric Value: pow() Function

The pow() function is used to raise a numeric value to the power of another numeric value. Its syntax is:

Float.pow(numeric_value1, numeric_value2);

The pow() function returns the result of raising numeric_value1 to the power of numeric_value2, i.e. numeric_value1numeric_value2. If any error occurs, it returns the invalid value.

Note that if numeric_value1 is smaller than zero, numeric_value2 must be an integer. If numeric_value1 is zero, numeric_value2 must be zero or greater than zero.

The following WMLScript example demonstrates how to use the pow() function:

x = Float.pow(10, 2);
y = Float.pow(10.5, 2.5);

After the execution of the above script, x has the floating-point value 100.0 and y has the floating-point value 357.251.

Previous Page Page 53 of 71 Next Page

Feedback Form (Expand)

What do you think about this web page?