Documentation Center

  • Trial Software
  • Product Updates

text2int

Convert a character string to an integer

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

text2int(text, <b>)

Description

text2int(text, b) converts a character string corresponding to an integer in b-adic representation to an integer of type DOM_INT.

It must consist of the first b characters in 0, 1, …, 9, A, B, …, Z, a, b, …, z. The letters are used to represent the b-adic digits larger than 9.

For bases larger than 10 but smaller than 37 the letters are not case sensitive. The lower case letters a, b, …, z are accepted: a = A = 10, …, z = Z = 35.

text2int is the inverse of int2text.

Examples

Example 1

Relative to the default base 10, text2int provides a mere datatype conversion from DOM_STRING to DOM_INT:

text2int("123"), text2int("-45678")

Example 2

The characters of the input string are interpreted as digits with respect to the specified base, the return value is a standard MuPAD® integer represented with respect to the decimal system. The following example converts integers from the base 2 and 16, respectively, to the base 10:

text2int("101", 2), text2int("101", 16)

The digit "3" does not exist in a binary representation:

text2int("103", 2)
Error: The argument is invalid. [text2int]

Example 3

For bases larger than 10 but smaller than 37, the letters are not case-sensitive:

text2int("3B9ACA00", 16), text2int("Z", 36) = text2int("z", 36)

For bases larger than 37 however, the case makes a difference:

text2int("Z", 62) <> text2int("z", 62)

Parameters

text

A character string

b

The base: an integer between 2 and 62. The default base is 10.

Return Values

Integer.

See Also

MuPAD Functions

Was this topic helpful?