|
Newsletters
|
|
|
|
|
WMLScript Reference
WMLScript Reference
WMLScript > Lang > parseFloat()
parseFloat() - The parseFloat Function
Usage: parseFloat(value)
Description: Returns an floating-poing value defined by the string value. The legal integer syntax is specified by the WMLScript numeric string grammar for decimal floating-point literals with the following additional parsing rule:
- Parsing ends when the first character is encountered that cannot be parsed as being part of the floating-poing representation.
The result is the parsed string converted to an floating-point value.
Example:var a = Lang.parseFloat("123.7"); // a = 123.7
var b = Lang.parseFloat(" +7.34e2 Hz"); // b = 7.34e2
var c = Lang.parseFloat(" 70e-2 F"); // c = 70.0e-2
var d = Lang.parseFloat("-.1 C"); // d = -0.1
var e = Lang.parseFloat(" 100 "); // e = 100.0
var e = Lang.parseFloat("Number: 5.5"); // f = invalid
var e = Lang.parseFloat("7.3e meters"); // g = invalid
var e = Lang.parseFloat("7.3e- m/s"); // h = invalid
Bookmark this page
|
|