![]() |
Murl Engine API
Version 2018.3
|
An integer of variable capacity. More...
#include <murl_math_big_integer.h>
An integer of variable capacity.
Public Member Functions | |
BigInteger () | |
The default constuctor. More... | |
BigInteger (const BigInteger &other, UInt32 reservedDigits) | |
Copy constructor with reserved digit count. More... | |
BigInteger (UInt32 value) | |
Copy constructor taking an unsigned 32 bit integer. More... | |
BigInteger (SInt32 value) | |
Copy constructor taking a signed 32 bit integer. More... | |
BigInteger (UInt64 value) | |
Copy constructor taking an unsigned 64 bit integer. More... | |
BigInteger (SInt64 value) | |
Copy constructor taking a signed 64 bit integer. More... | |
BigInteger (const String &value) | |
Copy constructor taking a decimal string. More... | |
void | Clear () |
Set the value to zero. | |
void | Set (const BigInteger &other) |
Copy the value to from a big-integer object. More... | |
void | Set (const BigInteger &other, UInt32 reservedDigits) |
Copy the value to from a big integer object and reserve digits. More... | |
void | SetSInt32 (SInt32 value) |
Copy the value to from an signed 32 bit integer. More... | |
void | SetUInt32 (UInt32 value) |
Copy the value to from an unsigned 32 bit integer. More... | |
void | SetSInt64 (SInt64 value) |
Copy the value to from an signed 64 bit integer. More... | |
void | SetUInt64 (UInt64 value) |
Copy the value to from an unsigned 64 bit integer. More... | |
void | SetString (const String &value) |
Convert the value to from a decimal string. More... | |
SInt32 | CompareTo (const BigInteger &other) const |
Compare a big-integer object to this. More... | |
SInt32 | CompareToAbsolute (const BigInteger &other) const |
Absolute compare a big-integer object to this. More... | |
UInt32 | GetLength () const |
Get the number of bytes used by the value. More... | |
UInt8 | GetByteAt (UInt32 index) const |
Get a byte from the value at a specified index. More... | |
Bool | SetByteAt (UInt32 index, UInt8 byte) |
Set a byte of the value at a specified index. More... | |
Bool | GetBitAt (UInt32 index) const |
Get a bit from the value at a specified index. More... | |
Bool | SetBitAt (UInt32 index, Bool bit) |
Set a bit of the value at a specified index. More... | |
Bool | IsZero () const |
Check if the value is zero. More... | |
Bool | IsOne () const |
Check if the value is one. More... | |
Bool | IsPositive () const |
Check if the value is positive. More... | |
Bool | IsNegative () const |
Check if the value is negative. More... | |
Bool | IsEven () const |
Check if the value is even. More... | |
Bool | IsOdd () const |
Check if the value is odd. More... | |
BigInteger | Invert () const |
Get the inverted value. More... | |
BigInteger | Abs () const |
Get the absolute value. More... | |
BigInteger | Add (const BigInteger &other) const |
Add this and a big-integer object. More... | |
BigInteger | Subtract (const BigInteger &other) const |
Subtract this and a big-integer object. More... | |
BigInteger | Multiply (const BigInteger &other) const |
Multiply this by a big-integer object. More... | |
BigInteger | Divide (const BigInteger &other) const |
Divide this by a big-integer object. More... | |
BigInteger | Divide (const BigInteger &other, BigInteger &remainder) const |
Divide this by a big-integer object. More... | |
BigInteger | Modulo (const BigInteger &other) const |
Divide this by a big-integer object and return the remainder. More... | |
BigInteger | Power (UInt32 n) const |
Get this raised to the power of an integer exponent. More... | |
BigInteger | Power (const BigInteger &n) const |
Get this raised to the power of a big-integer exponent. More... | |
BigInteger | PowerModulo (const BigInteger &n, const BigInteger &m) const |
Divide this raised to the power of a big-integer exponent by a big-integer object and return the remainder. More... | |
void | Multiply (const BigInteger &other, BigInteger &result) const |
Multiply this by a big-integer object. More... | |
BigInteger | GreatestCommonDivisor (const BigInteger &other) const |
Get the greatest common divisor of this. More... | |
void | InvertSelf () |
Invert the big-integer value. | |
void | AbsSelf () |
Make the big-integer value absolute. | |
void | MoveBytesLeftSelf (UInt32 bytes) |
Move left the bytes of the value. More... | |
void | MoveBytesRightSelf (UInt32 bytes) |
Move right the bytes of the value. More... | |
void | AddSelf (const BigInteger &other) |
Add a big-integer object to this. More... | |
void | SubtractSelf (const BigInteger &other) |
Subtract a big-integer object to this. More... | |
void | MultiplySelf (const BigInteger &other) |
Multiply this by a big-integer object. More... | |
void | DivideSelf (const BigInteger &other) |
Divide this by a big-integer object. More... | |
void | DivideSelf (const BigInteger &other, BigInteger &remainder) |
Divide this by a big-integer object. More... | |
void | ModuloSelf (const BigInteger &other) |
Divide this by a big-integer object and store the remainder. More... | |
void | PowerSelf (UInt32 n) |
Raise this to the power of an integer exponent. More... | |
void | PowerSelf (const BigInteger &n) |
Raise this to the power of a big-integer exponent. More... | |
void | PowerModuloSelf (const BigInteger &n, const BigInteger &m) |
Divide this raised to the power of a big-integer exponent by a big-integer object and store the remainder. More... | |
String | ToHexString () const |
Get the Hex character string of the value. More... | |
Data | ToData (UInt32 length=0) const |
Get the data object of the value. More... | |
UInt32 | ToUInt32 (UInt32 start, UInt32 count) const |
Get the 32 bit unsigned integer value. More... | |
UInt64 | ToUInt64 (UInt32 start, UInt32 count) const |
Get the 64 bit unsigned integer value. More... | |
bool | operator== (const BigInteger &rhs) const |
Equal to comparison operator. More... | |
bool | operator!= (const BigInteger &rhs) const |
Not equal to comparison operator. More... | |
bool | operator< (const BigInteger &rhs) const |
Less than operator. More... | |
bool | operator> (const BigInteger &rhs) const |
Greater than operator. More... | |
bool | operator<= (const BigInteger &rhs) const |
Less than or equal to operator. More... | |
bool | operator>= (const BigInteger &rhs) const |
Greater than or equal to operator. More... | |
BigInteger & | operator= (const BigInteger &value) |
Assignment operator for big-integer object. More... | |
BigInteger & | operator= (SInt32 value) |
Assignment operator for signed 32 bit integer. More... | |
BigInteger & | operator= (UInt32 value) |
Assignment operator for unsigned 32 bit integer. More... | |
BigInteger & | operator= (SInt64 value) |
Assignment operator for signed 64 bit integer. More... | |
BigInteger & | operator= (UInt64 value) |
Assignment operator for unsigned 64 bit integer. More... | |
BigInteger & | operator= (const String &value) |
Assignment operator for decimal string. More... | |
BigInteger | operator+ () const |
Unary plus operator. More... | |
BigInteger | operator- () const |
Unary minus operator. More... | |
BigInteger & | operator++ () |
Increment prefix operator. More... | |
BigInteger | operator++ (SInt32) |
Increment suffix operator. More... | |
BigInteger & | operator-- () |
Decrement prefix operator. More... | |
BigInteger | operator-- (SInt32) |
Decrement suffix operator. More... | |
BigInteger | operator<< (UInt32 bits) const |
Bitwise left shift operator. More... | |
BigInteger | operator>> (UInt32 bits) const |
Bitwise right shift operator. More... | |
BigInteger | operator+ (const BigInteger &rhs) const |
Addition operator. More... | |
BigInteger | operator- (const BigInteger &rhs) const |
Subtraction operator. More... | |
BigInteger | operator* (const BigInteger &rhs) const |
Multiplication operator. More... | |
BigInteger | operator/ (const BigInteger &rhs) const |
Division operator. More... | |
BigInteger | operator% (const BigInteger &rhs) const |
Modulo operator. More... | |
BigInteger & | operator<<= (UInt32 bits) |
In-place bitwise left shift operator. More... | |
BigInteger & | operator>>= (UInt32 bits) |
In-place bitwise right shift operator. More... | |
BigInteger & | operator+= (const BigInteger &other) |
In-place addition operator. More... | |
BigInteger & | operator-= (const BigInteger &other) |
In-place subtraction operator. More... | |
BigInteger & | operator*= (const BigInteger &other) |
In-place multiplication operator. More... | |
BigInteger & | operator/= (const BigInteger &other) |
In-place division operator. More... | |
BigInteger & | operator%= (const BigInteger &other) |
In-place modulo operator. More... | |
Static Public Member Functions | |
static BigInteger | FromData (const ConstData &data) |
Create a big-integer object from a data object. More... | |
static BigInteger | FromData (const UInt8 *data, UInt32 byteSize) |
Create a big-integer object from a memory location. More... | |
static BigInteger | FromHexString (const String &str) |
Create a big-integer object from a Hex character string. More... | |
Static Public Attributes | |
static const BigInteger | ZERO |
A predefined big-integer object with value zero. | |
static const BigInteger | ONE |
A predefined big-integer object with value one. | |
static const BigInteger | TWO |
A predefined big-integer object with value two. | |
Murl::Math::BigInteger::BigInteger | ( | ) |
The default constuctor.
The value is set to zero.
Murl::Math::BigInteger::BigInteger | ( | const BigInteger & | other, |
UInt32 | reservedDigits | ||
) |
Copy constructor with reserved digit count.
reservedDigits | The number of digits to reserve. |
other | The big-integer object to copy. |
Murl::Math::BigInteger::BigInteger | ( | UInt32 | value | ) |
Copy constructor taking an unsigned 32 bit integer.
value | The unsigned integer to copy. |
Murl::Math::BigInteger::BigInteger | ( | SInt32 | value | ) |
Copy constructor taking a signed 32 bit integer.
value | The signed integer to copy. |
Murl::Math::BigInteger::BigInteger | ( | UInt64 | value | ) |
Copy constructor taking an unsigned 64 bit integer.
value | The unsigned integer to copy. |
Murl::Math::BigInteger::BigInteger | ( | SInt64 | value | ) |
Copy constructor taking a signed 64 bit integer.
value | The signed integer to copy. |
Murl::Math::BigInteger::BigInteger | ( | const String & | value | ) |
Copy constructor taking a decimal string.
The sign can be specified by a '+' or '-' prefix character.
value | The decimal string to convert. |
|
static |
Create a big-integer object from a data object.
Takes the bytes from the data object:
data | The data object. |
|
static |
Create a big-integer object from a memory location.
Takes the bytes from the memory location:
data | The pointer to the memory location. |
byteSize | The number of bytes to read from the memory location. |
|
static |
Create a big-integer object from a Hex character string.
The sign can be specified by a '+' or '-' prefix character.
str | The Hex character string. |
void Murl::Math::BigInteger::Set | ( | const BigInteger & | other | ) |
Copy the value to from a big-integer object.
other | The big-integer object to copy. |
void Murl::Math::BigInteger::Set | ( | const BigInteger & | other, |
UInt32 | reservedDigits | ||
) |
Copy the value to from a big integer object and reserve digits.
reservedDigits | The number of digits to reserve. |
other | The big-integer object to copy. |
void Murl::Math::BigInteger::SetSInt32 | ( | SInt32 | value | ) |
Copy the value to from an signed 32 bit integer.
value | The signed 32 bit integer to copy. |
void Murl::Math::BigInteger::SetUInt32 | ( | UInt32 | value | ) |
Copy the value to from an unsigned 32 bit integer.
value | The unsigned 32 bit integer to copy. |
void Murl::Math::BigInteger::SetSInt64 | ( | SInt64 | value | ) |
Copy the value to from an signed 64 bit integer.
value | The signed 64 bit integer to copy. |
void Murl::Math::BigInteger::SetUInt64 | ( | UInt64 | value | ) |
Copy the value to from an unsigned 64 bit integer.
value | The unsigned 64 bit integer to copy. |
void Murl::Math::BigInteger::SetString | ( | const String & | value | ) |
Convert the value to from a decimal string.
The sign can be specified by a '+' or '-' prefix character.
value | The decimal string to convert. |
SInt32 Murl::Math::BigInteger::CompareTo | ( | const BigInteger & | other | ) | const |
Compare a big-integer object to this.
other | The big-integer object to compare. |
SInt32 Murl::Math::BigInteger::CompareToAbsolute | ( | const BigInteger & | other | ) | const |
Absolute compare a big-integer object to this.
other | The big-integer object to compare. |
UInt32 Murl::Math::BigInteger::GetLength | ( | ) | const |
Get the number of bytes used by the value.
Get a byte from the value at a specified index.
Index 0 is the least significant byte.
index | The index of the byte in range [0 .. GetLength() - 1]. |
Set a byte of the value at a specified index.
The value is expanded if the index is out of range. Index 0 is the least significant byte.
index | The index of the byte. |
byte | The byte to set. |
Get a bit from the value at a specified index.
Index 0 is the least significant bit.
index | The index of the bit in range [0 .. GetLength() * 8 - 1]. |
Set a bit of the value at a specified index.
The value is expanded if the index is out of range. Index 0 is the least significant bit.
index | The index of the bit. |
bit | The bit to set. |
Bool Murl::Math::BigInteger::IsZero | ( | ) | const |
Check if the value is zero.
Bool Murl::Math::BigInteger::IsOne | ( | ) | const |
Check if the value is one.
Bool Murl::Math::BigInteger::IsPositive | ( | ) | const |
Check if the value is positive.
Bool Murl::Math::BigInteger::IsNegative | ( | ) | const |
Check if the value is negative.
Bool Murl::Math::BigInteger::IsEven | ( | ) | const |
Check if the value is even.
Bool Murl::Math::BigInteger::IsOdd | ( | ) | const |
Check if the value is odd.
BigInteger Murl::Math::BigInteger::Invert | ( | ) | const |
Get the inverted value.
BigInteger Murl::Math::BigInteger::Abs | ( | ) | const |
Get the absolute value.
BigInteger Murl::Math::BigInteger::Add | ( | const BigInteger & | other | ) | const |
Add this and a big-integer object.
other | The big-integer object to add. |
BigInteger Murl::Math::BigInteger::Subtract | ( | const BigInteger & | other | ) | const |
Subtract this and a big-integer object.
other | The big-integer object to subtract. |
BigInteger Murl::Math::BigInteger::Multiply | ( | const BigInteger & | other | ) | const |
Multiply this by a big-integer object.
other | The big-integer object to multiply. |
BigInteger Murl::Math::BigInteger::Divide | ( | const BigInteger & | other | ) | const |
Divide this by a big-integer object.
other | The big-integer object to divide. |
BigInteger Murl::Math::BigInteger::Divide | ( | const BigInteger & | other, |
BigInteger & | remainder | ||
) | const |
Divide this by a big-integer object.
other | The big-integer object to divide. |
remainder | The remainder return value. |
BigInteger Murl::Math::BigInteger::Modulo | ( | const BigInteger & | other | ) | const |
Divide this by a big-integer object and return the remainder.
other | The big-integer object to divide. |
BigInteger Murl::Math::BigInteger::Power | ( | UInt32 | n | ) | const |
Get this raised to the power of an integer exponent.
n | The integer exponent. |
BigInteger Murl::Math::BigInteger::Power | ( | const BigInteger & | n | ) | const |
Get this raised to the power of a big-integer exponent.
n | The big-integer exponent. |
BigInteger Murl::Math::BigInteger::PowerModulo | ( | const BigInteger & | n, |
const BigInteger & | m | ||
) | const |
Divide this raised to the power of a big-integer exponent by a big-integer object and return the remainder.
n | The big-integer exponent. |
m | The big-integer object to divide. |
void Murl::Math::BigInteger::Multiply | ( | const BigInteger & | other, |
BigInteger & | result | ||
) | const |
Multiply this by a big-integer object.
other | The big-integer object to multiply. |
result | The multiplied big-integer object. |
BigInteger Murl::Math::BigInteger::GreatestCommonDivisor | ( | const BigInteger & | other | ) | const |
Get the greatest common divisor of this.
other | The big-integer object to divide. |
void Murl::Math::BigInteger::MoveBytesLeftSelf | ( | UInt32 | bytes | ) |
Move left the bytes of the value.
bytes | The number of bytes to move. |
void Murl::Math::BigInteger::MoveBytesRightSelf | ( | UInt32 | bytes | ) |
Move right the bytes of the value.
bytes | The number of bytes to move. |
void Murl::Math::BigInteger::AddSelf | ( | const BigInteger & | other | ) |
Add a big-integer object to this.
other | The big-integer object to add. |
void Murl::Math::BigInteger::SubtractSelf | ( | const BigInteger & | other | ) |
Subtract a big-integer object to this.
other | The big-integer object to subtract. |
void Murl::Math::BigInteger::MultiplySelf | ( | const BigInteger & | other | ) |
Multiply this by a big-integer object.
other | The big-integer object to multiply. |
void Murl::Math::BigInteger::DivideSelf | ( | const BigInteger & | other | ) |
Divide this by a big-integer object.
other | The big-integer object to divide. |
void Murl::Math::BigInteger::DivideSelf | ( | const BigInteger & | other, |
BigInteger & | remainder | ||
) |
Divide this by a big-integer object.
other | The big-integer object to divide. |
remainder | The remainder return value. |
void Murl::Math::BigInteger::ModuloSelf | ( | const BigInteger & | other | ) |
Divide this by a big-integer object and store the remainder.
other | The big-integer object to divide. |
void Murl::Math::BigInteger::PowerSelf | ( | UInt32 | n | ) |
Raise this to the power of an integer exponent.
n | The integer exponent. |
void Murl::Math::BigInteger::PowerSelf | ( | const BigInteger & | n | ) |
Raise this to the power of a big-integer exponent.
n | The big-integer exponent. |
void Murl::Math::BigInteger::PowerModuloSelf | ( | const BigInteger & | n, |
const BigInteger & | m | ||
) |
Divide this raised to the power of a big-integer exponent by a big-integer object and store the remainder.
n | The big-integer exponent. |
m | The big-integer object to divide. |
String Murl::Math::BigInteger::ToHexString | ( | ) | const |
Get the Hex character string of the value.
Get the data object of the value.
Stores the value bytes to a data object:
length | The number of bytes in the data object. Zero length adjusts the size of the data object to the number of bytes of the value. If the length is too small the most significant bytes are truncated. |
Get the 32 bit unsigned integer value.
start | The index of the byte to start in range [0 .. GetLength() - 1]. |
count | The number of bytes to get. |
Get the 64 bit unsigned integer value.
start | The index of the byte to start in range [0 .. GetLength() - 1]. |
count | The number of bytes to get. |
bool Murl::Math::BigInteger::operator== | ( | const BigInteger & | rhs | ) | const |
Equal to comparison operator.
rhs | The right hand side big-integer object to compare. |
bool Murl::Math::BigInteger::operator!= | ( | const BigInteger & | rhs | ) | const |
Not equal to comparison operator.
rhs | The right hand side big-integer object to compare. |
bool Murl::Math::BigInteger::operator< | ( | const BigInteger & | rhs | ) | const |
Less than operator.
rhs | The right hand side big-integer object to compare. |
bool Murl::Math::BigInteger::operator> | ( | const BigInteger & | rhs | ) | const |
Greater than operator.
rhs | The right hand side big-integer object to compare. |
bool Murl::Math::BigInteger::operator<= | ( | const BigInteger & | rhs | ) | const |
Less than or equal to operator.
rhs | The right hand side big-integer object to compare. |
bool Murl::Math::BigInteger::operator>= | ( | const BigInteger & | rhs | ) | const |
Greater than or equal to operator.
rhs | The right hand side big-integer object to compare. |
BigInteger& Murl::Math::BigInteger::operator= | ( | const BigInteger & | value | ) |
Assignment operator for big-integer object.
value | The value to assign. |
BigInteger& Murl::Math::BigInteger::operator= | ( | SInt32 | value | ) |
Assignment operator for signed 32 bit integer.
value | The value to assign. |
BigInteger& Murl::Math::BigInteger::operator= | ( | UInt32 | value | ) |
Assignment operator for unsigned 32 bit integer.
value | The value to assign. |
BigInteger& Murl::Math::BigInteger::operator= | ( | SInt64 | value | ) |
Assignment operator for signed 64 bit integer.
value | The value to assign. |
BigInteger& Murl::Math::BigInteger::operator= | ( | UInt64 | value | ) |
Assignment operator for unsigned 64 bit integer.
value | The value to assign. |
BigInteger& Murl::Math::BigInteger::operator= | ( | const String & | value | ) |
Assignment operator for decimal string.
The sign can be specified by a '+' or '-' prefix character.
value | The value to assign. |
BigInteger Murl::Math::BigInteger::operator+ | ( | ) | const |
Unary plus operator.
BigInteger Murl::Math::BigInteger::operator- | ( | ) | const |
Unary minus operator.
BigInteger& Murl::Math::BigInteger::operator++ | ( | ) |
Increment prefix operator.
BigInteger Murl::Math::BigInteger::operator++ | ( | SInt32 | ) |
Increment suffix operator.
BigInteger& Murl::Math::BigInteger::operator-- | ( | ) |
Decrement prefix operator.
BigInteger Murl::Math::BigInteger::operator-- | ( | SInt32 | ) |
Decrement suffix operator.
BigInteger Murl::Math::BigInteger::operator<< | ( | UInt32 | bits | ) | const |
Bitwise left shift operator.
bits | The number of bits to shift. |
BigInteger Murl::Math::BigInteger::operator>> | ( | UInt32 | bits | ) | const |
Bitwise right shift operator.
bits | The number of bits to shift. |
BigInteger Murl::Math::BigInteger::operator+ | ( | const BigInteger & | rhs | ) | const |
Addition operator.
rhs | The right hand side big-integer object to add. |
BigInteger Murl::Math::BigInteger::operator- | ( | const BigInteger & | rhs | ) | const |
Subtraction operator.
rhs | The right hand side big-integer object to subtract. |
BigInteger Murl::Math::BigInteger::operator* | ( | const BigInteger & | rhs | ) | const |
Multiplication operator.
rhs | The right hand side big-integer object to multiply. |
BigInteger Murl::Math::BigInteger::operator/ | ( | const BigInteger & | rhs | ) | const |
Division operator.
rhs | The right hand side big-integer object to divide. |
BigInteger Murl::Math::BigInteger::operator% | ( | const BigInteger & | rhs | ) | const |
Modulo operator.
rhs | The right hand side big-integer object to divide. |
BigInteger& Murl::Math::BigInteger::operator<<= | ( | UInt32 | bits | ) |
In-place bitwise left shift operator.
bits | The number of bits to shift. |
BigInteger& Murl::Math::BigInteger::operator>>= | ( | UInt32 | bits | ) |
In-place bitwise right shift operator.
bits | The number of bits to shift. |
BigInteger& Murl::Math::BigInteger::operator+= | ( | const BigInteger & | other | ) |
In-place addition operator.
other | The big-integer object to add. |
BigInteger& Murl::Math::BigInteger::operator-= | ( | const BigInteger & | other | ) |
In-place subtraction operator.
other | The big-integer object to subtract. |
BigInteger& Murl::Math::BigInteger::operator*= | ( | const BigInteger & | other | ) |
In-place multiplication operator.
other | The big-integer object to multiply. |
BigInteger& Murl::Math::BigInteger::operator/= | ( | const BigInteger & | other | ) |
In-place division operator.
other | The big-integer object to divide. |
BigInteger& Murl::Math::BigInteger::operator%= | ( | const BigInteger & | other | ) |
In-place modulo operator.
other | The big-integer object to divide. |