Added TBigInt.One
This commit is contained in:
parent
fad6e496c0
commit
cfb74da86b
|
@ -49,6 +49,7 @@ type
|
||||||
function CompareToAbsoluteValues(constref AOther: TBigInt): Integer;
|
function CompareToAbsoluteValues(constref AOther: TBigInt): Integer;
|
||||||
|
|
||||||
class function GetZero: TBigInt; static;
|
class function GetZero: TBigInt; static;
|
||||||
|
class function GetOne: TBigInt; static;
|
||||||
|
|
||||||
// Adds A and B, ignoring their signs and using ReturnNegative instead. The result is
|
// Adds A and B, ignoring their signs and using ReturnNegative instead. The result is
|
||||||
// Sign * (Abs(A) + Abs(B)),
|
// Sign * (Abs(A) + Abs(B)),
|
||||||
|
@ -76,6 +77,7 @@ type
|
||||||
property IsNegative: Boolean read FIsNegative;
|
property IsNegative: Boolean read FIsNegative;
|
||||||
property Sign: Integer read GetSign;
|
property Sign: Integer read GetSign;
|
||||||
class property Zero: TBigInt read GetZero;
|
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
|
// 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.
|
// 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;
|
CHalfDigitMax = (1 << CHalfBits) - 1;
|
||||||
|
|
||||||
CZero: TBigInt = (FDigits: (0); FIsNegative: False);
|
CZero: TBigInt = (FDigits: (0); FIsNegative: False);
|
||||||
|
COne: TBigInt = (FDigits: (1); FIsNegative: False);
|
||||||
|
|
||||||
{ TBigInt }
|
{ TBigInt }
|
||||||
|
|
||||||
|
@ -165,6 +168,11 @@ begin
|
||||||
Result := CZero;
|
Result := CZero;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TBigInt.GetOne: TBigInt;
|
||||||
|
begin
|
||||||
|
Result := COne;
|
||||||
|
end;
|
||||||
|
|
||||||
class function TBigInt.AddAbsoluteValues(constref AA, AB: TBigInt; const AReturnNegative: Boolean): TBigInt;
|
class function TBigInt.AddAbsoluteValues(constref AA, AB: TBigInt; const AReturnNegative: Boolean): TBigInt;
|
||||||
var
|
var
|
||||||
i, j, lenA, lenB, len, shorter: Integer;
|
i, j, lenA, lenB, len, shorter: Integer;
|
||||||
|
|
Loading…
Reference in New Issue