ASN1C C# Runtime Library  7.8
Public Member Functions | Static Public Member Functions | List of all members
BigInteger Class Reference

Public Member Functions

BigInteger Add (BigInteger op)
 
 BigInteger ()
 
 BigInteger (BigInteger x)
 
 BigInteger (byte[] value, int sign)
 
 BigInteger (System.String value)
 
 BigInteger (System.Int64 value)
 
 BigInteger (System.String value, int radix)
 
int BitLength ()
 
virtual int CompareTo (BigInteger value)
 
void DivideByInt (int divisor, out BigInteger quotient, out int remainder)
 
virtual bool Equals (long value)
 
override bool Equals (System.Object value)
 
byte [] GetData ()
 
override int GetHashCode ()
 
void Init (System.String val, int radix)
 
bool IsNegative ()
 
long LongValue ()
 
BigInteger Multiply (int factor)
 
void SecureDelete ()
 
void SetData (byte[] ivalue)
 
BigInteger Subtract (BigInteger op)
 
System.String ToString (int radix)
 
override System.String ToString ()
 

Static Public Member Functions

static implicit operator BigInteger (long value)
 

Detailed Description

This class represents an ASN.1 INTEGER built-in type. In this case, the values can be greater than 64 bits in size. This class is used in generated source code if the <bigInteger> qualifier is specified in a compiler configuration file.

Constructor & Destructor Documentation

◆ BigInteger() [1/6]

The default constructor sets the big integer value object reference to null.

◆ BigInteger() [2/6]

Construct a copy of the given BigInteger.

Parameters
x

◆ BigInteger() [3/6]

BigInteger ( byte []  value,
int  sign 
)

Create a new big integer object using the given binary representation for magnituded and sign.

Parameters
valueminimal, big-endian, representation of the magnitude (unsigned) of the value. For zero, an empty array.
signCan be -1 for negative, 0 for zero, or 1 for positive.

◆ BigInteger() [4/6]

BigInteger ( System.String  value)

This constructor creates a new big integer object and sets it to the string value passed in. String value may contain the prefix that describes the radix: 0x - hexadecimal, 0o - octal, 0b - binary. The string value without prefix assumes decimal value. The optional sign '-' may be specified at the beginning of the string to specify the negative value.

Parameters
valueString value

◆ BigInteger() [5/6]

BigInteger ( System.Int64  value)

This constructor creates a new big integer object and sets it to the int value passed in.

Parameters
valueInteger value

◆ BigInteger() [6/6]

BigInteger ( System.String  value,
int  radix 
)

This constructor creates a new big integer object and sets it to the string value passed in. String value may contain the prefix that describes the radix: 0x - hexadecimal, 0o - octal, 0b - binary. The string value without prefix assumes decimal value. The optional sign '-' may be specified at the beginning of the string to specify the negative value.

Parameters
valueString value
radixCan be 16 for hexadecimal, 8 for octal, 2 for binary or 10 for decimal

Member Function Documentation

◆ Add()

BigInteger Add ( BigInteger  op)

Return the result of adding op to this BigInteger. Does not modify this object.

Parameters
op
Returns

Referenced by Asn1BigInteger.Decode(), Asn1StringOID.Encode(), and Asn1BigInteger.Encode().

◆ BitLength()

int BitLength ( )

Returns the number of bits in the minimal two's-complement representation of this BigInteger, excluding a sign bit. For positive BigIntegers, this is equivalent to the number of bits in the ordinary binary representation. (Computes (ceil(log2(this < 0 ? -this : this+1))).)

Returns
number of bits in the minimal two's-complement representation of this BigInteger, excluding a sign bit.

Referenced by Asn1BigInteger.Decode(), Asn1BigInteger.Encode(), Asn1BigInteger.EncodeSigned(), and Asn1BigInteger.EncodeUnsigned().

◆ CompareTo()

virtual int CompareTo ( BigInteger  value)
virtual

This method compares this integer value to the given value.

Parameters
valueThe value to compare with the current object.
Returns
-1 if this object is less than value, 0 if this object is equal to value 1 if this object is greater than value

Referenced by Asn1BigInteger.Decode(), Asn1StringOID.Encode(), Asn1BigInteger.Encode(), Asn1BigInteger.EncodeUnsigned(), Asn1StringOID.ToString(), and Asn1StringOID.Validate().

◆ DivideByInt()

void DivideByInt ( int  divisor,
out BigInteger  quotient,
out int  remainder 
)

Set quotient and remainder to the result of dividing this big integer by divisor.

Parameters
divisor
quotient
remainder

Referenced by Asn1DecodeBuffer.DecodeRelOIDContentsBig().

◆ Equals() [1/2]

virtual bool Equals ( long  value)
virtual

This method compares this integer value to the given value for equality.

Parameters
valueThe long value to compare with the current Object.
Returns
true if the specified long value is equal to the current Object; otherwise, false.

Referenced by Asn1BigInteger.Decode(), Asn1BigInteger.Encode(), and Asn1BigInteger.Equals().

◆ Equals() [2/2]

override bool Equals ( System.Object  value)

This method compares this integer value to the given value for equality.

Parameters
valueThe Object to compare with the current Object. Object should be instance of BigInteger.
Returns
true if the specified Object is equal to the current Object; otherwise, false.

◆ GetData()

byte [] GetData ( )

This method provides the byte array representation of the integer value, in 2's complement form, using the minimal number of bytes (and at least 1 byte). The most significant byte is at index 0.

Returns
byte array for integer value

Referenced by Asn1BigInteger.DecodeValue(), Asn1BigInteger.Encode(), Asn1StringOID.EncodeIdentifier(), Asn1BigInteger.EncodeSigned(), Asn1BigInteger.EncodeUnsigned(), and Asn1BerEncodeBuffer.EncodeUnsignedBinaryNumber().

◆ GetHashCode()

override int GetHashCode ( )

Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.

Returns
A hash code for the current Object.

Referenced by Asn1BigInteger.GetHashCode().

◆ Init()

void Init ( System.String  val,
int  radix 
)

Translates the String representation of a Integer in the specified radix into a BigInteger. The String representation consists of an optional minus sign followed by a sequence of one or more digits in the specified radix. The String may not contain any extraneous Characters (whitespace, for example).

Parameters
valString representation of Integer.
radixradix to be used in interpreting string value.
Exceptions
System.FormatExceptionval is not a valid representation of a BigInteger in the specified radix, or invalid value of radix.

References Asn1Util.URShift().

◆ IsNegative()

bool IsNegative ( )

This method checks the Integer value is negative.

Returns
true if negative; otherwise false

Referenced by Asn1BerEncodeBuffer.EncodeUnsignedBinaryNumber().

◆ LongValue()

long LongValue ( )

Converts this BigInteger to a long. This conversion is analogous to the conversion from long to int: if this BigInteger is too big to fit in a long, only the low-order 64 bits are returned. Note that this conversion can lose information about the overall magnitude of the BigInteger value as well as return a result with the opposite sign.

Returns
this BigInteger converted to a long.

Referenced by Asn1BigInteger.Decode(), Asn1BigInteger.Encode(), Asn1BigInteger.EncodeSigned(), and Asn1BigInteger.EncodeUnsigned().

◆ Multiply()

BigInteger Multiply ( int  factor)

Return a BigInteger equal to this BigInteger multiplied by factor.

Parameters
factor
Returns

Referenced by Asn1StringOID.Encode(), and Asn1StringOID.ToString().

◆ operator BigInteger()

static implicit operator BigInteger ( long  value)
static

Overloaded implicit conversion operator for long to BigInteger value

◆ SecureDelete()

void SecureDelete ( )

This function clears the current value (by overwritting with zeros). Than sets the value to zero, and passes the old value to garbage collector.

◆ SetData()

void SetData ( byte []  ivalue)

This method sets the Integer value from byte array.

Parameters
ivaluebyte array of the integer value
Returns
Decoded integer value
See also
<seealso cref=GetData To retrieve Byte Array

Referenced by Asn1BigInteger.DecodeSigned(), Asn1BigInteger.DecodeUnsigned(), and Asn1BigInteger.DecodeValue().

◆ Subtract()

BigInteger Subtract ( BigInteger  op)

Subtract given op from this value and return the result. This object is not modified.

Parameters
op
Returns

Referenced by Asn1BigInteger.Decode(), Asn1DecodeBuffer.DecodeRelOIDContentsBig(), and Asn1BigInteger.Encode().

◆ ToString() [1/2]

System.String ToString ( int  radix)

Returns the String representation of this BigInteger in the given radix. If the radix is invalid, it will default to 10 (as is the case for Int32.ToString). The a minus sign is prepended if appropriate. This method is compatible with BigInteger(String, int) constructor.

Parameters
radixradix of the String representation.
Returns
String representation of this BigInteger in the given radix.
See also
<seealso cref=System.Int32.ToString Integer ToString methods

Referenced by Asn1BigInteger.Decode(), Asn1BigInteger.Encode(), and Asn1BigInteger.ToString().

◆ ToString() [2/2]

override System.String ToString ( )

This method will return a string representation of the integer value. The format is the ASN.1 value format for this type..

Returns
Stringified representation of the value