diff --git a/UBigInt.pas b/UBigInt.pas index 7d22c07..5a31b72 100644 --- a/UBigInt.pas +++ b/UBigInt.pas @@ -78,6 +78,8 @@ type class property Zero: TBigInt read GetZero; function CompareTo(constref AOther: TBigInt): Integer; function TryToInt64(out AOutput: Int64): Boolean; + // TODO: ToString is currently for debug output only. + function ToString: string; class function FromInt64(const AValue: Int64): TBigInt; static; class function FromHexadecimalString(const AValue: string): TBigInt; static; class function FromBinaryString(const AValue: string): TBigInt; static; @@ -498,6 +500,21 @@ begin end; end; +function TBigInt.ToString: string; +var + i: Integer; +begin + if FIsNegative then + Result := '-' + else + Result := ''; + for i := 0 to Length(FDigits) - 2 do + Result := Result + '(' + IntToStr(FDigits[i]) + ' + 2^32 * '; + Result := Result + IntToStr(FDigits[Length(FDigits) - 1]); + for i := 0 to Length(FDigits) - 2 do + Result := Result + ')'; +end; + class function TBigInt.FromInt64(const AValue: Int64): TBigInt; var absVal: Int64;