即答ミスしたお詫びに分岐無しバージョンで

function HexLength(a:Cardinal):Integer;
begin
a := a or 1;
a := a or (a shr 16);
a := a or (a shr 8);
a := a or (a shr 4);
a := a or (a shr 2);
a := (a or (a shr 1)) and $11111111;
a := a+(a shr 16);
a := a+(a shr 8);
a := a+(a shr 4);
Result:=( a and $f);
end;