ソースを参照

add Clone() method for BigInteger

Ugochukwu Mmaduekwe 6 年 前
コミット
076be6f303
1 ファイル変更13 行追加0 行削除
  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;
     function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
     inline;
     inline;
 {$ENDIF DELPHI}
 {$ENDIF DELPHI}
+    function Clone(): TBigInteger; inline;
+
     class function BitCnt(i: Int32): Int32; static;
     class function BitCnt(i: Int32): Int32; static;
 
 
     /// <summary>
     /// <summary>
@@ -2040,6 +2042,17 @@ begin
 
 
 end;
 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;
 function TBigInteger.GetLowestSetBit: Int32;
 begin
 begin
   if (Fsign = 0) then
   if (Fsign = 0) then