WMLScript » Float » Float.sqrt

Syntax:
Float.sqrt(value)
value
The mandatory value parameter can be any positive single-precision floating-point number or any positive integer number (including zero). The floating-point number must reside on or between the largest number and the smallest nonzero number supported by the browser. These boundary values can be determined using the Float.maxFloat and Float.minFloat functions.

Returns the square root of a floating-point or integer number.

The Float.sqrt function returns the square root of any positive floating-point or integer number. If the number is negative, invalid will be returned.

If the browser does not support floating-point arithmetic operations, then the browser will not recognize the Float Library, nor any of the member functions. In this case, the Float.sqrt function returns invalid.

The Float.pow function can be used to raise a number to a power.

Examples

Code:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.WAPforum.org/DTD/wml_1.1.xml">
<wml>

<card id="card1">
   <p>
   sqrt example
   </p>
   <do type="accept">
      <go href="SqrtExample.wmls#findsqrt()" />
   </do>
</card>

<card id="card2">
<p>
   original number = $(number)
   <br />
   square root = $(sqrtnumber)
</p>
</card>

</wml>
Explanation:

Code for SqrtExample.wml

Language(s): WML
Code:
extern function findsqrt()
{
   var mydefault = "71.348";
   var result = Dialogs.prompt("Enter a positive number", mydefault);
   var sqrtnum = Float.sqrt(result);
   WMLBrowser.setVar("number", result);
   WMLBrowser.setVar("sqrtnumber", sqrtnum);
   WMLBrowser.go("SqrtExample.wml#card2");
};
Explanation:

Code for SqrtExample.wmls

Language(s): WML

See Also: