Base-16 representation: Difference between revisions

Line 7:
=={{header|Ring}}==
<lang ring>
load "stdlib.ring"
see "working..." + nl
baseList = ["a","b","c","d","e","f"]
decList = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
baseList = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]
row = 1
limit = 200
Line 17 ⟶ 15:
num = 0
flag = 1
hex = decimaltobasehex(n,16)
lenHex = len(hex)
for m = 1 to lenHex
ind = find(baseList,hex[m])
if ind < 111
num = num + 1
ok
Line 35 ⟶ 33:
 
see nl + "done..." + nl
 
func decimaltobase(nr,base)
binList = []
binary = 0
remainder = 1
while(nr != 0)
remainder = nr % base
ind = find(decList,remainder)
rem = baseList[ind]
add(binList,rem)
nr = floor(nr/base)
end
binlist = reverse(binList)
binList = list2str(binList)
binList = substr(binList,nl,"")
return binList
</lang>
{{out}}
2,468

edits