|Home | Tutorial | Classes | Functions | QSA Workbench | Language | Qt API | QSA Articles | Qt Script for Applications |

[Prev: parseFloat()] [Home] [Next: startTimer()]

#### parseInt()

`parseInt( string, optBase )`

Parses the string and returns the integer that the string represents in the given base optBase, or NaN if the parse fails. If the base isn't specified, the base is determined as follows:

- base 16 (hexadecimal) if the first non-whitespace characters are "0x" or "0X";

- base 8 (octal) if the first non-whitespace character is "0";

- base 10 otherwise.

Leading and trailing whitespace are ignored. If the string contains a number followed by non-numeric characters, the value of the number is returned and the trailing characters ignored.

Example:

        var i = parseInt( "24" );       // i == 24
        var h = parseInt( "0xFF" );     // h == 255
        var x = parseInt( " 459xyz " ); // x == 459

See also parseFloat().

[Prev: parseFloat()] [Home] [Next: startTimer()]