O'Reilly logo

Learning WML, and WMLScript by Martin Frost

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Type Conversion

WMLScript operators implicitly convert their operands into the types they require. For example, the * operator for multiplication can operate on either integers or floating points, so the operands must first be converted into one of these types.

If an argument can’t be converted, the result is invalid. Note that there are no explicit conversions to invalid, since no operator actually requires an invalid value.

Conversion to String

  • Integers convert to a string representing their value in decimal. For example, the integer 1234 converts to the string "1234", and the integer -42 converts to the string "-42".

  • Floating-point numbers convert to a string representing their value. The exact form of this string may differ from implementation to implementation. For example, the floating-point number 0.2 may convert to any of the strings "0.2", "2e-1", ".2", "0.2e+0", and so on.

  • Boolean true is converted to the string "true", and Boolean false is converted to the string "false".

  • invalid can’t be converted to a string.

Conversion to Integer

  • A string containing a valid decimal integer is converted into that integer. Any other string can’t be converted to an integer. For example, the strings "1234" and "+1234" both convert to the integer 1234, but the string "1234x" can’t be converted.

  • No floating-point value can be converted to an integer.

  • Boolean true is converted to 1, and Boolean false is converted to 0.

  • invalid can’t be converted to an integer.

Conversion to Floating-Point Number ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required