Martin Larsen on Fri, 02 Dec 2005 17:48:37 +0100


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

Re: Using hexadecimal with gp


Hello everybody,
I'm trying to use the GP calculator in order to evaluate the
expression X^N mod N

I'm able to evaluate this expression, however I would like to use, as
input to the Mod( ) number expressed in hexadecimal notation.
However I tried
Mod(0x77, 0x11),
Mod(77h, 11h)
but none of this notation is accepted.
I searched for hex on the pdf file provided as help with pari, but I
wasn't able to find reference to this aspect.
Any help will be appreciated.

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)}

Regards
Martin