Siebel eScript Language Reference > Methods Reference > Conversion Methods >

Convert String to Integer Method


The Convert String to Integer method converts an alphanumeric string to an integer. It returns an integer. If it cannot convert the value that the string argument contains to a number, then it returns the following value:

NaN

For more information, see NaN Numbers.

Format

parseInt(string [,radix])

Table 87 describes the arguments for the Convert String to Integer method.

Table 87. Arguments for the Convert String to Integer Method
Argument
Description

string

The string that this method converts.

radix

The base of the number system that this method uses in the return value. For example, if you set the radix argument to 8, then it returns the value as an octal number.

Usage

If you do not specify the radix argument or if the value that the radix argument contains is zero, then the Convert String to Integer method uses a value of 10 for the radix unless the value that the string argument contains begins with one of the following values:

  • The character pairs 0x or 0X. It uses a value of 16 for the radix.
  • A zero and a valid octal digit. It uses a value of 8 for the radix. Any number zero through seven is a valid octal digit.

CAUTION:  If the passed string includes a leading zero, such as 05, then the Convert String to Integer method interprets the number as on octal. An argument that it interprets as an invalid octal creates a return value of zero. The values 08 and 09 are examples of invalid octal values.

This method handles the string in the same way as the Convert String to Floating-Point Number method. For more information, see How the Convert String to Floating-Point Number Method Handles the String.

Example

The following example returns a result of negative 234:

var num = parseInt(" -234.37 profit");

Siebel eScript Language Reference Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.