Here is the function that I use to create a UInt64 result from an array of numbers and a base value.
function BaseNToInteger(const ABase: Cardinal; const ADigits: Array of Byte): UInt64; var i: Integer; begin Result := 0; for i := 0 to (Length(ADigits) - 1) do begin Result := Result + (ADigits[i] * Power(i, ABase)); end; end;
[Please do not worry about the Power () function; I wrote my own, which uses cardinals and produces UInt64 results.]
This is the easy part.
Since my math skills seem to have rusted over the years, the hard part that I struggle with is these:
1) For a given UInt64 value, how can I create an ADigits array for a given base value (where base> 1)?
2) How to determine the length of the ADigits array for a given base value (where base> 1), which will represent a given UInt64 value?
Adem source share