Non-decimal radices/Convert: Difference between revisions
simplify Python encoder
(Added Quackery.) |
(simplify Python encoder) |
||
Line 2,600:
<lang python>digits = "0123456789abcdefghijklmnopqrstuvwxyz"
def baseN(num, b):
return
;Iterative:
<lang>digits =
def baseN(num, b):
result = []
while num
num, d = divmod(num, b)
result
result.append(digits[num])
return ''.join(result[::-1])</lang>
Line 2,622 ⟶ 2,619:
<pre>In [1: baseN(26, 16)
Out[1]: '1a'</pre>
=={{header|Quackery}}==
|