Previous Up Next

6.4.2  Writing an integer in an arbitrary base b: convert

The convert command does various kinds of conversions depending on the option given as the second argument (see Section 6.23.26). convertir is a synonym for convert.

One thing that convert can do is convert integers to arbitrary bases and back to the default base, both with the option base.

To convert an integer into the list of its “digits” in base b:


Example.
Input:

convert(123,base,8)

Output:


3,7,1

To check the answer, input 0173 (see Section 6.4.1) or horner(revlist([3,7,1]),8) (see Section 6.27.19 and Section 6.40.15) or convert([3,7,1],base,8). The result will be 123.


The base used for convert can be any integer greater than 1.


Example.
Input:

convert(142,base,12)

Output:


10,11


To convert the its “digits” in base b into a base 10 integer:


Examples.


Previous Up Next