#include <big_integer.h>
This is the interface for the BigInteger data type. The data is reference-counted and a copy will automatically be created if a non-const function is called.
@MAXON_ANNOTATION{refclass=false}
Static Public Member Functions | |
static MAXON_METHOD BigIntegerInterface * | Zero () |
static MAXON_METHOD BigIntegerInterface * | One () |
static MAXON_METHOD BigIntegerInterface * | MinusOne () |
static MAXON_METHOD Result< void > | DescribeIO (const DataSerializeInterface &stream) |
Private Member Functions | |
MAXON_INTERFACE_NONVIRTUAL (BigIntegerInterface, MAXON_REFERENCE_COPY_ON_WRITE, "net.maxon.interface.biginteger") | |
|
private |
|
static |
Returns a BigInteger value of zero.
|
static |
Returns a BigInteger value of one.
|
static |
Returns a BigInteger value of minus one.
MAXON_METHOD Result<void> Set | ( | Char | c | ) |
MAXON_METHOD Result<void> Set | ( | UChar | c | ) |
MAXON_METHOD Result<void> Set | ( | Int16 | i | ) |
MAXON_METHOD Result<void> Set | ( | UInt16 | u | ) |
MAXON_METHOD Result<void> Set | ( | Int32 | i | ) |
MAXON_METHOD Result<void> Set | ( | UInt32 | u | ) |
MAXON_METHOD Result<void> Set | ( | Int64 | i | ) |
MAXON_METHOD Result<void> Set | ( | UInt64 | u | ) |
MAXON_METHOD Result<void> SetRandom | ( | Int | bitCount, |
SecureRandomProvider | provider = SecureRandomProvider() |
||
) |
Assigns a random value to this BigInteger. The number is always positive.
[in] | bitCount | The number of bits to set. This value must be greater than 0. |
[in] | provider | A secure random provider that can be used with SecureRandom. If nullptr is passed an unsecure default provider is chosen. |
MAXON_METHOD Result<void> SetRandomPrime | ( | Int | bitCount, |
UInt | certainty, | ||
SecureRandomProvider | provider = SecureRandomProvider() |
||
) |
Assigns a random prime number value to this BigInteger. The number is always positive, odd and the (bitCount - 1) bit will be set.
[in] | bitCount | The number of bits to set. This value must be greater than 1. |
[in] | certainty | The generated number is a prime number with a probability of 1-0.5**certainty. This parameter must be greater than 0. The execution time of this function raises with the certainty. |
[in] | provider | A secure random provider that can be used with SecureRandom. If nullptr is passed an unsecure default provider is chosen. |
MAXON_METHOD Result<void> Set | ( | const Block< const Byte > & | mem, |
Bool | littleEndian | ||
) |
Sets the value of this BigInteger.
[in] | mem | A memory block that contains the new value in the specified format. |
[in] | littleEndian | If this value is true, the parameter is treated as little-endian ("Intel format"), otherwise big-endian ("Motorola format"). |
MAXON_METHOD Result<void> Set | ( | const String & | str | ) |
Sets the value of this BigInteger.
[in] | str | The new value, represented as a decimal string. The string may only contain decimal digits. |
MAXON_METHOD Result<void> SetHex | ( | const String & | str | ) |
Sets the value of this BigInteger.
[in] | str | The new value, represented as a hexadecimal string. The string may only contain hexadecimal digits. |
MAXON_METHOD Bool IsEven | ( | ) | const |
Checks if the value is even.
MAXON_METHOD Bool IsOdd | ( | ) | const |
Checks if the value is odd.
MAXON_METHOD Bool IsOne | ( | ) | const |
Checks if the value is one.
MAXON_METHOD Bool IsZero | ( | ) | const |
Checks if the value is zero.
MAXON_METHOD Bool IsNegative | ( | ) | const |
Checks if the value is negative.
MAXON_METHOD Bool IsPowerOfTwo | ( | ) | const |
Checks if the value is a power of 2.
MAXON_METHOD Result<Bool> IsProbablyPrime | ( | UInt | certainty | ) | const |
Checks if the number is probably prime. The result will be false if the value of this BigInteger is smaller than one.
[in] | certainty | The certainty with which the number is checked for being a prime number. This parameter must be greater than 0. |
MAXON_METHOD Int Sign | ( | ) | const |
Gets the sign.
MAXON_METHOD Int GetHighestNonSignBit | ( | ) | const |
Gets the highest bit position that is different than the sign bit. This is the position incremented by one for negative numbers.
MAXON_METHOD Int GetLowestSetBit | ( | ) | const |
Gets the lowest bit position that is zero.
MAXON_METHOD Int GetLowestClearedBit | ( | ) | const |
Gets the lowest bit position that is zero.
MAXON_METHOD Bool IsBitSet | ( | Int | bit | ) | const |
Checks if the bit at a certain position is set.
[in] | bit | The bit position to set. |
MAXON_METHOD UChar GetLowestBits8U | ( | ) | const |
Get the lowest 8 bits.
MAXON_METHOD Char GetLowestBits8S | ( | ) | const |
Get the lowest 8 bits.
MAXON_METHOD UInt16 GetLowestBits16U | ( | ) | const |
Get the lowest 16 bits.
MAXON_METHOD Int16 GetLowestBits16S | ( | ) | const |
Get the lowest 16 bits.
MAXON_METHOD UInt32 GetLowestBits32U | ( | ) | const |
Get the lowest 32 bits.
MAXON_METHOD Int32 GetLowestBits32S | ( | ) | const |
Get the lowest 32 bits.
MAXON_METHOD UInt64 GetLowestBits64U | ( | ) | const |
Get the lowest 64 bits.
MAXON_METHOD Int64 GetLowestBits64S | ( | ) | const |
Get the lowest 64 bits.
MAXON_METHOD Result<void> GetDataCopy | ( | Bool | littleEndian, |
BaseArray< UChar > & | data | ||
) | const |
Gets a copy of the internal data.
[in] | littleEndian | If this value is true, the data is written in little-endian format, otherwise big-endian. |
[out] | data | The BaseArray that will hold the data copy in the specified format. |
MAXON_METHOD Result<void> Add | ( | const BigIntegerInterface * | b | ) |
Performs the add operation.
[in] | b | The value to add to this. |
MAXON_METHOD Result<void> Sub | ( | const BigIntegerInterface * | b | ) |
Performs the subtract operation.
[in] | b | The value to subtract to this. |
MAXON_METHOD Result<void> Inc | ( | ) |
Increments the value by one.
MAXON_METHOD Result<void> Dec | ( | ) |
Decrements the value by one.
MAXON_METHOD Result<void> Mul | ( | const BigIntegerInterface * | b | ) |
Performs the multiply operation.
[in] | b | The value to multiply to this. |
MAXON_METHOD Result<void> Div | ( | const BigIntegerInterface * | b | ) |
Performs the divide operation.
[in] | b | The value with which is this to divide. The result is 0, if b is 0 or if its absolute value is bigger than the absolute value of this. |
MAXON_METHOD Result<void> Mod | ( | const BigIntegerInterface * | b | ) |
Performs the modulo operation.
[in] | b | The modulus. The result is 0, if b is 0. |
MAXON_METHOD Result<void> DivMod | ( | const BigIntegerInterface * | b, |
BigInteger & | r | ||
) |
Performs the divide and modulo operation.
[in] | b | The value with which is this to divide. The result is 0, if b is 0 or if its absolute value is bigger than the absolute value of this. |
[out] | r | The remainder of the division will be stored in r. The value of r is undefined if b is 0. |
MAXON_METHOD Result<void> Pow | ( | const BigIntegerInterface * | b | ) |
Performs the power operation.
[in] | b | Raises this to the power of b. The result will be 0 if b is negative. |
MAXON_METHOD Result<void> PowMod | ( | const BigIntegerInterface * | b, |
const BigIntegerInterface * | mod | ||
) |
Performs the power operation and takes the result modulo mod.
[in] | b | Raises this to the power of b. The result will be 0 if b is negative. |
[in] | mod | The modulo value. |
MAXON_METHOD Result<void> GreatestCommonDivisor | ( | const BigIntegerInterface * | b | ) |
Calculates the greatest common divisor of this and b. Both values must be greater than zero, otherwise the value will remain unchanged.
[in] | b | Another BigInteger. |
MAXON_METHOD Result<Bool> MultiplicativeInverse | ( | const BigIntegerInterface * | m | ) |
Calculates the multiplicative inverse of this modulo m. This must be smaller than m. The new result of this will be greater or equal to zero and smaller than m.
[in] | m | Another BigInteger. This value must be greater than zero. |
MAXON_METHOD Result<void> LeftShift | ( | Int | s | ) |
Performs the Left shift operation. If the number of bits to shift is less than 0 the bits are shifted right.
[in] | s | The number of bits to shift. |
MAXON_METHOD Result<void> RightShift | ( | Int | s | ) |
Performs the Right shift operation. If the number of bits to shift is less than 0 the bits are shifted left.
[in] | s | The number of bits to shift. |
MAXON_METHOD Result<void> Negate | ( | ) |
Negates the value.
MAXON_METHOD Result<void> SetBit | ( | Int | bit | ) |
Sets a bit in the integer.
[in] | bit | The position of the bit which is to set. |
MAXON_METHOD Result<void> ClearBit | ( | Int | bit | ) |
Clears a bit in the integer.
[in] | bit | The position of the bit which is to clear. |
MAXON_METHOD Result<void> ToggleBit | ( | Int | bit | ) |
Toggles a bit in the integer.
[in] | bit | The position of the bit which is to toggle. |
MAXON_METHOD COMPARERESULT Compare | ( | const BigIntegerInterface * | arg2 | ) | const |
Compares this with another BigInteger value.
[in] | arg2 | The other BigInteger value to compare with. |
MAXON_METHOD HashInt GetHashCode | ( | ) | const |
Returns the hash code of this @CLASS.
MAXON_METHOD UniqueHash GetUniqueHashCode | ( | ) | const |
Returns the 128-bit hash value of this @CLASS. The implementation ensures uniform distribution, so for practical purposes you can safely assume that two objects are equal if their hash values are equal.
MAXON_METHOD String ToString | ( | const FormatStatement * | formatStatement = nullptr | ) | const |
Returns a readable string of the content.
[in] | formatStatement | Nullptr or additional formatting instruction. Currently no additional formatting instructions are supported. |
|
static |
Describe all elements of this class for I/O operations.
[in] | stream | The stream that is used to register the class members. |