Algorithm Math Delphi

function OctToDec(d:integer):integer;
var
x,sum:integer;
begin
x := 0; sum := 0;
while( d > 0 ) do
begin
if( x = 0 ) then
sum := sum + (d mod 10)
else
sum := sum + (d mod 10) * round(power(8,x));
d := d div 10;
inc(x);
end;
result := sum;
end;