convert number from one base to another base
Although micropython can do these convertions using int(), hex(), oct() and bin(). The convertion is coded in Python for fun.
There are two functions defined, first function converts from arbitrary base to base 10, second fucntion converts from base 10 to new base
- tobase10(s, base)
- convert number to base 10
- s: string representation of number
- base: integer stating number base of s
- returns: integer version of s in base 10
- frombase10(x, base)
- convert number from base 10 to another base
- x: integer representation of number
- base: integer stating number base to convert to
- returns: string representation of x in new base