WMLScript Float Standard Library Quick Reference

Preferences - Do not show ads

WMLScript's Float standard library contains functions that help us perform a number of floating-point arithmetic operations.



WMLScript Quick Reference: Functions in the Float Standard Library

ceil(numeric_value)

Calculates the ceiling of numeric_value, i.e. it returns the smallest integer that is greater than numeric_value if numeric_value is a fraction, and returns numeric_value if numeric_value is an integer.

Example:

var w = Float.ceil(10.4);
var x = Float.ceil(10.5);
var y = Float.ceil(11);
var z = Float.ceil(-10.5);

w, x and y have the integral value 11.
z has the integral value -10.

floor(numeric_value)

Calculates the floor of numeric_value, i.e. it returns the largest integer that is smaller than numeric_value if numeric_value is a fraction, and returns numeric_value if numeric_value is an integer.

Example:

var w = Float.floor(11.4);
var x = Float.floor(11.5);
var y = Float.floor(11);
var z = Float.floor(-10.5);

w, x and y have the integral value 11.
z has the integral value -11.

int(numeric_value)

Truncates the fractional part of numeric_value.

Example:

var x = Float.int(5.5678);
var y = Float.int(-5.5678);

x has the integral value 5.
y has the integral value -5.

maxFloat()

Finds the maximum floating-point number supported, which should be 3.40282347E+38.

minFloat()

Finds the smallest positive nonzero floating-point number supported, which should be 1.17549435E-38.

pow(numeric_value1, numeric_value2)

Raises numeric_value1 to the power of numeric_value2, i.e. it calculates the result of numeric_value1numeric_value2.

Example:

var x = Float.pow(2, 3);
var y = Float.pow(10.5, 2.5);

x has the floating-point value 8.0.
y has the floating-point value 357.251.

round(numeric_value)

Returns the rounding of numeric_value.

Example:

var w = Float.round(10);
var x = Float.round(10.4);
var y = Float.round(10.5);
var z = Float.round(-10.5);

w has the integral value 10.
x has the integral value 10.
y has the integral value 11.
z has the integral value -10.

sqrt(numeric_value)

Calculates the square root of numeric_value.

Example:

var x = Float.sqrt(100);
var y = Float.sqrt(14);

x has the floating-point value 10.0.
y has the floating-point value 3.74166.


Preferences - Do not show ads


Page 4 of 6 Previous Page | Next Page
Contents at a Glance
Print this Web Page | | Back to Top

Feedback Form (Expand)

What do you think about this web page?






Standard WMLScript Libraries Reference - Table of Contents Standard WMLScript Libraries Reference - Contents at a Glance Preferences - Change Color Scheme Preferences - Do Not Show Ads Previous Page Next Page