Browse Source

add IsEven() functionality to TBigInteger

Ugochukwu Mmaduekwe 6 years ago
parent
commit
94b88ac5c9
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/libraries/cryptolib4pascal/ClpBigInteger.pas

+ 6 - 0
src/libraries/cryptolib4pascal/ClpBigInteger.pas

@@ -424,6 +424,7 @@ type
     function SetBit(n: Int32): TBigInteger;
     function ClearBit(n: Int32): TBigInteger;
     function FlipBit(n: Int32): TBigInteger;
+    function IsEven(): Boolean; inline;
 
     function GetLowestSetBit(): Int32;
 
@@ -1960,6 +1961,11 @@ begin
   Result := &Xor(One.ShiftLeft(n));
 end;
 
+function TBigInteger.IsEven(): Boolean;
+begin
+  Result := not(TestBit(0));
+end;
+
 function TBigInteger.Gcd(const value: TBigInteger): TBigInteger;
 var
   r, u, v: TBigInteger;