The definition of the corner permutation
coordinate
The corner permutation coordinate is given by a number from 0 to 40319
(8!  1).
In this example, we use the permutation of the Rmove again, but we ignore
the orientations now.
URF

UFL

ULB

UBR

DFR

DLF

DBL

DRB

c:DFR

c:UFL

c:ULB

c:URF

c:DRB

c:DLF

c:DBL

c:UBR


1

1

3

0

1

1

4

We define a natural order on the corners by URF<UFL<ULB<UBR<DFR<DLF<DBL<DRB.
The number in the third row  below a corner XXX in the second row 
gives the number of all corners left of XXX, whose orders are higher than
the order of XXX.
Above the entry 4 we have for example the
corner UBR.
From the 7 corners left of UBR, 4 corners have a higher order  DFR, DLF,
DBL, DRB.
Above the entry 1 we have for example the
corner DLF.
From the 5 corners left of DLF, only 1 corner has a higher order  DRB.
We build the permutation coordinate with the numbers of the third row.
1*1! + 1*2! + 3*3! + 0*4! + 1*5! + 1*6!
+ 4*7! = 21021
So we use a system with variable base here.
The following function from cubicube.pas does the job.
function CubieCube.CornPermCoord: Word;
var i,j: Corner; x,s: Integer;
begin
x:= 0;
for i:= DRB downto Succ(URF) do
begin
s:=0;
for j:= Pred(i) downto URF do
begin
if PCorn^[j].c>PCorn^[i].c then
Inc(s);
end;
x:= (x+s)*Ord(i);
end;
Result:=x;
end;
