Non-decimal radices/Convert: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: added REXX language.)
Line 901: Line 901:


=={{header|Python}}==
=={{header|Python}}==
Converting from string to number is easy:
<lang python>i = int('1a',16) # returns the integer 26</lang>
Converting from number to string is harder:
<lang python>digits = "0123456789abcdefghijklmnopqrstuvwxyz"
<lang python>digits = "0123456789abcdefghijklmnopqrstuvwxyz"
def baseN(num,b):
def baseN(num,b):
Line 917: Line 920:


k = 26
k = 26
s = baseN(k,16) # returns the string 1a
s = baseN(k,16) # returns the string 1a</lang>
i = int('1a',16) # returns the integer 26</lang>


=={{header|REXX}}==
=={{header|REXX}}==