Browse Source

add Clone() method for BigInteger

Ugochukwu Mmaduekwe 6 years ago
parent
commit
076be6f303
1 changed files with 13 additions and 0 deletions
  1. 13 0
      CryptoLib/src/Math/ClpBigInteger.pas

+ 13 - 0
CryptoLib/src/Math/ClpBigInteger.pas

@@ -434,6 +434,8 @@ type
     function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
     inline;
 {$ENDIF DELPHI}
+    function Clone(): TBigInteger; inline;
+
     class function BitCnt(i: Int32): Int32; static;
 
     /// <summary>
@@ -2040,6 +2042,17 @@ begin
 
 end;
 
+function TBigInteger.Clone(): TBigInteger;
+begin
+  Result := Default (TBigInteger);
+  Result.Fmagnitude := System.Copy(Fmagnitude);
+  Result.Fsign := Fsign;
+  Result.FnBits := FnBits;
+  Result.FnBitLength := FnBitLength;
+  Result.FmQuote := FmQuote;
+  Result.FIsInitialized := FIsInitialized;
+end;
+
 function TBigInteger.GetLowestSetBit: Int32;
 begin
   if (Fsign = 0) then