Added TBigInt.One

This commit is contained in:
Stefan Müller 2024-05-23 21:07:11 +02:00
parent fad6e496c0
commit cfb74da86b
1 changed files with 8 additions and 0 deletions

View File

@ -49,6 +49,7 @@ type
function CompareToAbsoluteValues(constref AOther: TBigInt): Integer;
class function GetZero: TBigInt; static;
class function GetOne: TBigInt; static;
// Adds A and B, ignoring their signs and using ReturnNegative instead. The result is
// Sign * (Abs(A) + Abs(B)),
@ -76,6 +77,7 @@ type
property IsNegative: Boolean read FIsNegative;
property Sign: Integer read GetSign;
class property Zero: TBigInt read GetZero;
class property One: TBigInt read GetOne;
// Returns the index of the most significant bit, i.e. returns integer k, where 2^k is the largest power of 2 that
// is less than or equal to the absolute value of the number itself. Returns -1 if the given number is 0.
@ -115,6 +117,7 @@ const
CHalfDigitMax = (1 << CHalfBits) - 1;
CZero: TBigInt = (FDigits: (0); FIsNegative: False);
COne: TBigInt = (FDigits: (1); FIsNegative: False);
{ TBigInt }
@ -165,6 +168,11 @@ begin
Result := CZero;
end;
class function TBigInt.GetOne: TBigInt;
begin
Result := COne;
end;
class function TBigInt.AddAbsoluteValues(constref AA, AB: TBigInt; const AReturnNegative: Boolean): TBigInt;
var
i, j, lenA, lenB, len, shorter: Integer;