int2text -- convert an integer
to a character string
Introductionint2text(n, b) converts the integer
n to a string that corresponds to the b-adic
representation of n.
Call(s)int2text(n <, b>)
Parametersn |
- | an integer |
b |
- | the base: an integer between 2 and 36. The default base is 10. |
Returns
Related
Functionscoerce, expr2text, genpoly, numlib::g_adic, tbl2text, text2expr, text2int, text2list, text2tbl
Detailsint2text consists of the first
b characters in
0, 1, ..., 9, A, B, ..., Z.For bases larger than 10, the letters represent the
b-adic digits larger than 9: A = 10, B =
11, ..., Z = 35.int2text provides the conversion from decimal
representation to binary, octal, or hexadecimal representation,
respectively.int2text is the inverse of text2int.int2text
to represent b-adic numbers. The function numlib::g_adic provides an
alternative representation via lists.int2text is a function of the system kernel.
Example
1Relative to the default base 10, int2text
provides a mere datatype conversion from DOM_INT to DOM_STRING:
>> int2text(123), int2text(-45678)
"123", "-45678"
Example
2The decimal integer 32 has the following binary representation:
>> int2text(32, 2)
"100000"
The decimal integer 10^9 has the following hexadecimal representation:
>> int2text(10^9, 16)
"3B9ACA00"
Example
3Negative integers can be converted as well:
>> int2text(-15, 8)
"-17"