next up previous contents index
suivant: Integers (and Gaussian Integers) monter: The CAS functions précédent: Transform a string into   Table des matières   Index


Write an integer in a b basis: convert

convert or convertir can do different kind of conversions depending on the option given as the second argument.

To convert an integer n into the list of its coefficients in a basis b, the option is base. The arguments of convert or convertir are an integer n, base and b the value of the basis.
convert or convertir returns the list of coefficients in a b basis of the integer n Input :

convert(123,base,8)
Output :
[3,7,1]
To check the answer, input expr("0173") or horner(revlist([3,7,1]),8) or convert([3,7,1],base,8) and output is 123
Input :
convert(142,base,12)
Output :
[10,11]

To convert the list of coefficients in a basis b of an integer n, the option is also base. convert or convertir returns the integer n.
Input :

convert([3,7,1],base,8)
Or
horner(revlist([3,7,1]),8)
Output :
123
Input :
convert([10,11],base,12)
Or
horner(revlist([10,11]),12)
Output :
142


next up previous contents index
suivant: Integers (and Gaussian Integers) monter: The CAS functions précédent: Transform a string into   Table des matières   Index
giac documentation written by Renée De Graeve and Bernard Parisse