Convert an integer to a character string

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


int2text(n, <b>)


int2text(n, b) converts the integer n to a string that corresponds to the b-adic representation of n.

The string returned by int2text consists of the first b characters in 0, 1, …, 9, A, B, …, Z, a, b, …, z. For bases larger than 10, the letters represent the b-adic digits larger than 9: A = 10, B = 11, …, Z = 35, a = 36, b = 37, …, z = 61.

For the bases 2, 8, or 16, int2text provides the conversion from decimal representation to binary, octal, or hexadecimal representation, respectively.

int2text is the inverse of text2int.

Since the output of the numerical datatypes in MuPAD® uses the decimal representation, strings are used by int2text to represent b-adic numbers. The function numlib::g_adic provides an alternative representation via lists.


Example 1

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

int2text(123), int2text(-45678)

Example 2

The decimal integer 32 has the following binary representation:

int2text(32, 2)

The decimal integer 109 has the following hexadecimal representation:

int2text(10^9, 16)

... and with the base 62:

int2text(10^9, 62)

Example 3

Negative integers can be converted as well:

int2text(-15, 8)



An integer


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

Return Values

character string.