//The following is intellectual property. It may //be use for investigation, if want to use for //commercial, please contact me at my email //santo_mar_d_velaz@hotmail.com

s= null; // -s if n>>s and s if n<<s.

t=null; // traits or ^ powers. 6 trits=1 Tryte.

n=null; // 10base number to be change.

y=null; // 10base # into the new 10base #.

M=3^t; // Max possibilities.

fS=s%t; // to filter out the excessive ^ powers.

cS=t+fS; // to know if n<<s || n>>s.

aS=cS%t; // the final filter, variable we use.

x=n(3^aS)/M; // to get the whole #s

r=n(3^aS)%M; // to get the remainders #s

switch (r):

case (r>M/2)

y=x+r-M;

break;

case (0<=r<=M/2 && x>=0)

y=x+r;

break;

case (r==0 && x<0)

y=x+3^aS;

break;

case (aS<-1 && r<(-2M)/3 || aS <=t-1 &&

r<(-2M) /3

y=x+r-M;

break;