Table of Contents

Class BigInteger

Namespace
Org.BouncyCastle.Math
Assembly
BouncyCastle.Cryptography.dll
[Serializable]
public sealed class BigInteger : IComparable, IComparable<BigInteger>, IEquatable<BigInteger>
Inheritance
BigInteger
Implements
Inherited Members

Constructors

BigInteger(byte[])

public BigInteger(byte[] bytes)

Parameters

bytes byte[]

BigInteger(byte[], bool)

public BigInteger(byte[] bytes, bool bigEndian)

Parameters

bytes byte[]
bigEndian bool

BigInteger(byte[], int, int)

public BigInteger(byte[] bytes, int offset, int length)

Parameters

bytes byte[]
offset int
length int

BigInteger(byte[], int, int, bool)

public BigInteger(byte[] bytes, int offset, int length, bool bigEndian)

Parameters

bytes byte[]
offset int
length int
bigEndian bool

BigInteger(int, byte[])

public BigInteger(int sign, byte[] bytes)

Parameters

sign int
bytes byte[]

BigInteger(int, byte[], bool)

public BigInteger(int sign, byte[] bytes, bool bigEndian)

Parameters

sign int
bytes byte[]
bigEndian bool

BigInteger(int, byte[], int, int)

public BigInteger(int sign, byte[] bytes, int offset, int length)

Parameters

sign int
bytes byte[]
offset int
length int

BigInteger(int, byte[], int, int, bool)

public BigInteger(int sign, byte[] bytes, int offset, int length, bool bigEndian)

Parameters

sign int
bytes byte[]
offset int
length int
bigEndian bool

BigInteger(int, int, Random)

public BigInteger(int bitLength, int certainty, Random random)

Parameters

bitLength int
certainty int
random Random

BigInteger(int, Random)

public BigInteger(int sizeInBits, Random random)

Parameters

sizeInBits int
random Random

BigInteger(int, ReadOnlySpan<byte>)

public BigInteger(int sign, ReadOnlySpan<byte> bytes)

Parameters

sign int
bytes ReadOnlySpan<byte>

BigInteger(int, ReadOnlySpan<byte>, bool)

public BigInteger(int sign, ReadOnlySpan<byte> bytes, bool bigEndian)

Parameters

sign int
bytes ReadOnlySpan<byte>
bigEndian bool

BigInteger(string)

public BigInteger(string value)

Parameters

value string

BigInteger(string, int)

public BigInteger(string str, int radix)

Parameters

str string
radix int

Fields

Five

public static readonly BigInteger Five

Field Value

BigInteger

Four

public static readonly BigInteger Four

Field Value

BigInteger

One

public static readonly BigInteger One

Field Value

BigInteger

Six

public static readonly BigInteger Six

Field Value

BigInteger

Ten

public static readonly BigInteger Ten

Field Value

BigInteger

Three

public static readonly BigInteger Three

Field Value

BigInteger

Two

public static readonly BigInteger Two

Field Value

BigInteger

Zero

public static readonly BigInteger Zero

Field Value

BigInteger

Properties

BitCount

public int BitCount { get; }

Property Value

int

BitLength

public int BitLength { get; }

Property Value

int

IntValue

public int IntValue { get; }

Property Value

int

IntValueExact

public int IntValueExact { get; }

Property Value

int

LongValue

public long LongValue { get; }

Property Value

long

LongValueExact

public long LongValueExact { get; }

Property Value

long

SignValue

public int SignValue { get; }

Property Value

int

Methods

Abs()

public BigInteger Abs()

Returns

BigInteger

Add(BigInteger)

public BigInteger Add(BigInteger value)

Parameters

value BigInteger

Returns

BigInteger

And(BigInteger)

public BigInteger And(BigInteger value)

Parameters

value BigInteger

Returns

BigInteger

AndNot(BigInteger)

public BigInteger AndNot(BigInteger val)

Parameters

val BigInteger

Returns

BigInteger

Arbitrary(int)

public static BigInteger Arbitrary(int sizeInBits)

Parameters

sizeInBits int

Returns

BigInteger

ClearBit(int)

public BigInteger ClearBit(int n)

Parameters

n int

Returns

BigInteger

CompareTo(BigInteger)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(BigInteger other)

Parameters

other BigInteger

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

CompareTo(object)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(object obj)

Parameters

obj object

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes obj in the sort order.
Zero This instance occurs in the same position in the sort order as obj.
Greater than zero This instance follows obj in the sort order.

Exceptions

ArgumentException

obj is not the same type as this instance.

Divide(BigInteger)

public BigInteger Divide(BigInteger val)

Parameters

val BigInteger

Returns

BigInteger

DivideAndRemainder(BigInteger)

public BigInteger[] DivideAndRemainder(BigInteger val)

Parameters

val BigInteger

Returns

BigInteger[]

Equals(BigInteger)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(BigInteger other)

Parameters

other BigInteger

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

FlipBit(int)

public BigInteger FlipBit(int n)

Parameters

n int

Returns

BigInteger

Gcd(BigInteger)

public BigInteger Gcd(BigInteger value)

Parameters

value BigInteger

Returns

BigInteger

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

GetLengthofByteArray()

public int GetLengthofByteArray()

Returns

int

GetLengthofByteArrayUnsigned()

public int GetLengthofByteArrayUnsigned()

Returns

int

GetLengthofUInt32Array()

public int GetLengthofUInt32Array()

Returns

int

GetLengthofUInt32ArrayUnsigned()

public int GetLengthofUInt32ArrayUnsigned()

Returns

int

GetLowestSetBit()

public int GetLowestSetBit()

Returns

int

IsProbablePrime(int)

public bool IsProbablePrime(int certainty)

Parameters

certainty int

Returns

bool

Max(BigInteger)

public BigInteger Max(BigInteger value)

Parameters

value BigInteger

Returns

BigInteger

Min(BigInteger)

public BigInteger Min(BigInteger value)

Parameters

value BigInteger

Returns

BigInteger

Mod(BigInteger)

public BigInteger Mod(BigInteger m)

Parameters

m BigInteger

Returns

BigInteger

ModDivide(BigInteger, BigInteger)

public BigInteger ModDivide(BigInteger y, BigInteger m)

Parameters

y BigInteger
m BigInteger

Returns

BigInteger

ModInverse(BigInteger)

public BigInteger ModInverse(BigInteger m)

Parameters

m BigInteger

Returns

BigInteger

ModMultiply(BigInteger, BigInteger)

public BigInteger ModMultiply(BigInteger y, BigInteger m)

Parameters

y BigInteger
m BigInteger

Returns

BigInteger

ModPow(BigInteger, BigInteger)

public BigInteger ModPow(BigInteger e, BigInteger m)

Parameters

e BigInteger
m BigInteger

Returns

BigInteger

ModSquare(BigInteger)

public BigInteger ModSquare(BigInteger m)

Parameters

m BigInteger

Returns

BigInteger

Multiply(BigInteger)

public BigInteger Multiply(BigInteger val)

Parameters

val BigInteger

Returns

BigInteger

Negate()

public BigInteger Negate()

Returns

BigInteger

NextProbablePrime()

public BigInteger NextProbablePrime()

Returns

BigInteger

Not()

public BigInteger Not()

Returns

BigInteger

Or(BigInteger)

public BigInteger Or(BigInteger value)

Parameters

value BigInteger

Returns

BigInteger

Pow(int)

public BigInteger Pow(int exp)

Parameters

exp int

Returns

BigInteger

ProbablePrime(int, Random)

public static BigInteger ProbablePrime(int bitLength, Random random)

Parameters

bitLength int
random Random

Returns

BigInteger

RabinMillerTest(int, Random)

public bool RabinMillerTest(int certainty, Random random)

Parameters

certainty int
random Random

Returns

bool

Remainder(BigInteger)

public BigInteger Remainder(BigInteger n)

Parameters

n BigInteger

Returns

BigInteger

SetBit(int)

public BigInteger SetBit(int n)

Parameters

n int

Returns

BigInteger

ShiftLeft(int)

public BigInteger ShiftLeft(int n)

Parameters

n int

Returns

BigInteger

ShiftRight(int)

public BigInteger ShiftRight(int n)

Parameters

n int

Returns

BigInteger

Square()

public BigInteger Square()

Returns

BigInteger

Subtract(BigInteger)

public BigInteger Subtract(BigInteger n)

Parameters

n BigInteger

Returns

BigInteger

TestBit(int)

public bool TestBit(int n)

Parameters

n int

Returns

bool

ToByteArray()

public byte[] ToByteArray()

Returns

byte[]

ToByteArray(Span<byte>)

public void ToByteArray(Span<byte> output)

Parameters

output Span<byte>

ToByteArrayUnsigned()

public byte[] ToByteArrayUnsigned()

Returns

byte[]

ToByteArrayUnsigned(Span<byte>)

public void ToByteArrayUnsigned(Span<byte> output)

Parameters

output Span<byte>

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

ToString(int)

public string ToString(int radix)

Parameters

radix int

Returns

string

ToUInt32ArrayBigEndian(Span<uint>)

[CLSCompliant(false)]
public void ToUInt32ArrayBigEndian(Span<uint> output)

Parameters

output Span<uint>

ToUInt32ArrayBigEndianUnsigned(Span<uint>)

[CLSCompliant(false)]
public void ToUInt32ArrayBigEndianUnsigned(Span<uint> output)

Parameters

output Span<uint>

ToUInt32ArrayLittleEndian(Span<uint>)

[CLSCompliant(false)]
public void ToUInt32ArrayLittleEndian(Span<uint> output)

Parameters

output Span<uint>

ToUInt32ArrayLittleEndianUnsigned(Span<uint>)

[CLSCompliant(false)]
public void ToUInt32ArrayLittleEndianUnsigned(Span<uint> output)

Parameters

output Span<uint>

ValueOf(int)

public static BigInteger ValueOf(int value)

Parameters

value int

Returns

BigInteger

ValueOf(long)

public static BigInteger ValueOf(long value)

Parameters

value long

Returns

BigInteger

Xor(BigInteger)

public BigInteger Xor(BigInteger value)

Parameters

value BigInteger

Returns

BigInteger