Non-decimal radices/Convert: Difference between revisions
Content deleted Content added
→{{header|Euphoria}}: Euphoria example added |
GP |
||
Line 783:
- : int = 42
</pre>
=={{header|PARI/GP}}==
<lang parigp>toBase(n,b)={
my(s="",t);
while(n,
t=n%b;
n\=b;
s=Str(if(t<=9,t,Strchr(Vecsmall([87+t]))),s)
);
if(#s,s,"0")
};
fromBase(s,b)={
my(t=0);
s=Vecsmall(s);
forstep(i=#s,1,-1,
t=b*t+s[i]-if(s[i]<58,48,87)
);
t
};</lang>
=={{header|Perl}}==
|