WMLScript » Float » Float.ceil

Syntax:
Float.ceil(value)
value
The mandatory value parameter can be any positive or negative single-precision floating-point number or any positive or negative 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.

Rounds a floating-point number up to the next larger integer value.

The Float.ceil function returns the next largest integer (in a positive direction) for a given floating-point number. If the number is already an integer, then that same integer value 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.ceil function returns invalid.

The similar Float.floor function returns the next smallest integer.

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>
   ceil example
   </p>
   <do type="accept">
      <go href="WMLSceil.wmls#CeilExample.wmls#findceil()" />
   </do>
</card>

<card id="card2">
<p>
   original number = $(number)
   <br />
   ceil number = $(ceilnumber)
</p>
</card>

</wml>
Explanation:

Code for CeilExample.wml

Language(s): WML
Code:
extern function findceil()
{
   var mydefault = "71.348";
   var result = Dialogs.prompt("Enter any number", mydefault);
   var ceilnum = Float.ceil(result);
   WMLBrowser.setVar("number", result);
   WMLBrowser.setVar("ceilnumber", ceilnum);
   WMLBrowser.go("CeilExample.wml#card2");
};
Explanation:

Code for CeilExample.wmls

Language(s): WML

See Also: