Martin Larsen on Mon, 05 Dec 2005 19:40:59 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Using hexadecimal with gp



Maybe this would work:

hextodec(s)=
[snip]

Correction,

Perhaps I should also bring a fast version with error-check. If checking for bad input is redundant, remove the "if-line".
hextodec(s)=
{local(v=Vec(s),
a=10,b=11,c=12,d=13,e=14,f=15,A=10,B=11,C=12,D=13,E=14,F=15,h);
if(#setunion(Set(v),Vec("0123456789ABCDEFabcdef"))>22,error);
for(i=1,#v,h=shift(h,4)+eval(v[i]));h}

Martin