Data types define the type of data the variable will hold. Examples of data types are:
var flag = true
var number = 12
var temperature = 37.7
var number = "XII"
var except = invalid
WMLScript 1.1 supports data types internally only. You do not have to specify the variable type, and any variable can contain any type of data at any given time. A fifth data type, invalid, is used when a data type needs to be differentiated from the other internal data types.
This section describes the following data types, all of which are supported by WMLScript 1.1:
The range supported by WMLScript 1.1 for integer values.
The supported value range is -2147483648 to 2147483647. You can use Lang library functions to get these values during run time.
|
|
Maximum representable integer value. |
|
|
Minimum representable integer value. |
The minimum and maximum values and the precision for floating-point values.
The maximum supported value is 3.40282347E+38.
The minimum positive nonzero value (at least the normalized precision must be supported): 1.17549435E-38 or smaller.
You can use the Float library functions to get these values during run time:
|
Maximum representable floating-point value supported. |
|
Minimum representable floating-point value supported. |
The special floating-point number types are handled by using the following rules:
If an operation results in a floating-point number that is not part of the set of finite real numbers (not a number, positive infinity, and so on), supported by the single- precision floating-point format, the result is invalid.
If an operation results in a floating-point underflow, the result is zero (0.0).
Negative zero and positive zero are equal and indistinguishable.
Temporary combinations of letters, digits, or special characters.
You can use string literals to initialize string variables.
You can manipulate string values with WMLScript 1.1 operators and the functions specified in the standard String library.
var msg = "Hello";
var len = String.length(msg);
msg = msg + ' Worlds!';
You can use boolean values:
To initialize or assign a value to a variable.
In statements that require a boolean value as one of the parameters.
Boolean values can be a literal or the result of a logical expression evaluation.
var truth = true;
var lie = !true;