FUNCTION:  Float.sqrt

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"?>

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

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


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);

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