FUNCTION:  Float.sqrt

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

Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information