parseInteger#

swordfish.function.parseInteger()#

parseInteger parses X into an integer of the specified type in specified radix. If it encounters a character that is not a numeral in the specified radix, it ignores it and all succeeding characters and returns the integer value parsed up to that point. An exception will be thrown if the first character is invalid.

Parameters:
  • X (Constant) – A STRING scalar, vector, pair or matrix.

  • type (Constant) – Specifies the data type of the integer, which can be CHAR, SHORT, INT or LONG.

  • radix (Constant, optional) –

    An integer in [2, 16] that represents the radix (the base in mathematical numeral systems) of the integer. The default value is 10.

    • For radix 2, only ‘0’ and ‘1’ are allowed.

    • For radix 11-16, ‘A’/’a’ to ‘F’/’f’ (case insensitive) are used for 10-15.

    • Specifically for radix 16, leading ‘0x’ or ‘0X’ is allowed.

Returns:

A CHAR/SHORT/INT/LONG scalar/vector/pair/matrix of the same shape as X.

Return type:

Constant