Martin Larsen on Fri, 02 Dec 2005 19:16:55 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Using hexadecimal with gp |
Maybe this would work: hextodec(s)= {local(v=Vecsmall(s), sett=Set([0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f])); sum(i=0,#v-1,(setsearch(sett,Strchr(bitor(v[#v-i],32)))-1)*16^i)}
Correction, I'm scrambling for an easy way to enter "sett" hextodec(s)= \\s string {local(v=Vecsmall(s), sett=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"]); sum(i=0,#v-1,(setsearch(sett,Strchr(bitor(v[#v-i],32)))-1)*16^i)}