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.
<?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>
Code for SqrtExample.wml
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");
};
Code for SqrtExample.wmls