## `text2int` -- convert a character string to an integer

#### Introduction

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

#### Call(s)

`text2int(text <, b>)`

#### Parameters

`text` | - | a character string
`b` | - | the base: an integer between 2 and 36. The default base is 10.

#### Returns

an integer.

#### Related Functions

`coerce`, `expr2text`, `genpoly`, `int2text`, `numlib::g_adic`, `tbl2text`, `text2expr`, `text2list`, `text2tbl`

#### Details

- The text is interpreted as a `b`-adic representation. Its must consist of the first `b` characters in 0, 1, .., 9, A, B, .., Z. Also lower case letters a, b, .., z are accepted. For bases larger than 10, the letters can be used to represent the `b`-adic digits larger than 9: a = A = 10, .., z = Z = 35.
- `text2int` is the inverse of `int2text`.
- `text2int` is a function of the system kernel.

#### Example 1

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

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

                                    123, -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)

                                      5, 257

The digit ```3`'' does not exist in a binary representation:

    >> text2int("103", 2)

          Error: Illegal argument [text2int]

#### Example 3

For bases larger than 10, letters represent the `b`-adic digits larger than 9:

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

                                1000000000, 35 = 35

#### Changes

- no changes

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000