Murl Engine Lua Addon API  Version 1.0 beta
Murl.Math.BigInteger

An integer of variable capacity.


Table members

Members


Murl.Math.BigInteger.ZERO

A predefined big-integer object with value zero.

Returns
Murl.Math.BigInteger

Murl.Math.BigInteger.ONE

A predefined big-integer object with value one.

Returns
Murl.Math.BigInteger

Murl.Math.BigInteger.TWO

A predefined big-integer object with value two.

Returns
Murl.Math.BigInteger


Functions


Murl.Math.BigInteger.FromData(data)

Create a big-integer object from a data object. Takes the bytes from the data object:

  • The first byte is the most significant byte.
  • The last byte is the least significant byte.
  • The sign is always positive.

Murl.Math.BigInteger FromData(Murl.ConstData data)

Parameters
dataThe data object.
Returns
Murl.Math.BigInteger The created big-integer object.

Murl.Math.BigInteger.FromHexString(str)

Create a big-integer object from a Hex character string. The sign can be specified by a '+' or '-' prefix character.

Murl.Math.BigInteger FromHexString(String str)

Parameters
strThe Hex character string.
Returns
Murl.Math.BigInteger The created big-integer object.

Murl.Math.BigInteger.new()

The default constructor. The value is set to zero.

Murl.Math.BigInteger new()

Returns
Murl.Math.BigInteger

Murl.Math.BigInteger.new(value)

Copy constructor taking a signed 64 bit integer.

Murl.Math.BigInteger new(Integer value)

Parameters
valueThe signed integer to copy.
Returns
Murl.Math.BigInteger

Murl.Math.BigInteger.new(value)

Copy constructor taking a decimal string. The sign can be specified by a '+' or '-' prefix character.

Murl.Math.BigInteger new(String value)

Parameters
valueThe decimal string to convert.
Returns
Murl.Math.BigInteger

Murl.Math.BigInteger.new(other, reservedDigits)

Copy constructor with reserved digit count.

Murl.Math.BigInteger new(Murl.Math.BigInteger other, Integer reservedDigits)

Parameters
reservedDigitsThe number of digits to reserve.
otherThe big-integer object to copy.
Returns
Murl.Math.BigInteger


Methods


Clear()

Set the value to zero.

Clear()


Set(other)

Copy the value to from a big-integer object.

Set(Murl.Math.BigInteger other)

Parameters
otherThe big-integer object to copy.

Set(other, reservedDigits)

Copy the value to from a big integer object and reserve digits.

Set(Murl.Math.BigInteger other, Integer reservedDigits)

Parameters
reservedDigitsThe number of digits to reserve.
otherThe big-integer object to copy.

SetSInt32(value)

Copy the value to from an signed 32 bit integer.

SetSInt32(Integer value)

Parameters
valueThe signed 32 bit integer to copy.

SetUInt32(value)

Copy the value to from an unsigned 32 bit integer.

SetUInt32(Integer value)

Parameters
valueThe unsigned 32 bit integer to copy.

SetSInt64(value)

Copy the value to from an signed 64 bit integer.

SetSInt64(Integer value)

Parameters
valueThe signed 64 bit integer to copy.

SetUInt64(value)

Copy the value to from an unsigned 64 bit integer.

SetUInt64(Integer value)

Parameters
valueThe unsigned 64 bit integer to copy.

SetString(value)

Convert the value to from a decimal string. The sign can be specified by a '+' or '-' prefix character.

SetString(String value)

Parameters
valueThe decimal string to convert.

CompareTo(other)

Compare a big-integer object to this.

Integer CompareTo(Murl.Math.BigInteger other)

Parameters
otherThe big-integer object to compare.
Returns
Integer 0 if equal, -1 if this is lesser than the other or 1 this is greater than the other.

CompareToAbsolute(other)

Absolute compare a big-integer object to this.

Integer CompareToAbsolute(Murl.Math.BigInteger other)

Parameters
otherThe big-integer object to compare.
Returns
Integer 0 if equal, -1 if this is lesser than the other or 1 this is greater than the other.

GetLength()

Get the number of bytes used by the value.

Integer GetLength()

Returns
Integer The number of bytes used by the value.

GetByteAt(index)

Get a byte from the value at a specified index. Index 0 is the least significant byte.

Integer GetByteAt(Integer index)

Parameters
indexThe index of the byte in range [0 .. GetLength() - 1].
Returns
Integer The byte from the value at the specified index or zero if the index is out of range.

SetByteAt(index, byte)

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.

Boolean SetByteAt(Integer index, Integer byte)

Parameters
indexThe index of the byte.
byteThe byte to set.
Returns
Boolean true if successful.

GetBitAt(index)

Get a bit from the value at a specified index. Index 0 is the least significant bit.

Boolean GetBitAt(Integer index)

Parameters
indexThe index of the bit in range [0 .. GetLength() * 8 - 1].
Returns
Boolean The bit from the value at the specified index or false if the index is out of range.

SetBitAt(index, bit)

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.

Boolean SetBitAt(Integer index, Boolean bit)

Parameters
indexThe index of the bit.
bitThe bit to set.
Returns
Boolean true if successful.

IsZero()

Check if the value is zero.

Boolean IsZero()

Returns
Boolean true if the value is zero.

IsOne()

Check if the value is one.

Boolean IsOne()

Returns
Boolean true if the value is one.

IsPositive()

Check if the value is positive.

Boolean IsPositive()

Returns
Boolean true if the value is positive.

IsNegative()

Check if the value is negative.

Boolean IsNegative()

Returns
Boolean true if the value is negative.

IsEven()

Check if the value is even.

Boolean IsEven()

Returns
Boolean true if the value is even.

IsOdd()

Check if the value is odd.

Boolean IsOdd()

Returns
Boolean true if the value is odd.

Invert()

Get the inverted value.

Murl.Math.BigInteger Invert()

Returns
Murl.Math.BigInteger The inverted big-integer object.

Abs()

Get the absolute value.

Murl.Math.BigInteger Abs()

Returns
Murl.Math.BigInteger The absolute big-integer object.

Add(other)

Add this and a big-integer object.

Murl.Math.BigInteger Add(Murl.Math.BigInteger other)

Parameters
otherThe big-integer object to add.
Returns
Murl.Math.BigInteger The added big-integer object.

Subtract(other)

Subtract this and a big-integer object.

Murl.Math.BigInteger Subtract(Murl.Math.BigInteger other)

Parameters
otherThe big-integer object to subtract.
Returns
Murl.Math.BigInteger The subtracted big-integer object.

Multiply(other)

Multiply this by a big-integer object.

Murl.Math.BigInteger Multiply(Murl.Math.BigInteger other)

Parameters
otherThe big-integer object to multiply.
Returns
Murl.Math.BigInteger The multiplied big-integer object.

Multiply(other, result)

Multiply this by a big-integer object.

Murl.Math.BigInteger Multiply(Murl.Math.BigInteger other, Murl.Math.BigInteger result)

Parameters
otherThe big-integer object to multiply.
resultThe multiplied big-integer object.
Returns
Murl.Math.BigInteger result The multiplied big-integer object.

Divide(other)

Divide this by a big-integer object.

Murl.Math.BigInteger Divide(Murl.Math.BigInteger other)

Parameters
otherThe big-integer object to divide.
Returns
Murl.Math.BigInteger The divided big-integer object.

Divide(other, remainder)

Divide this by a big-integer object.

Murl.Math.BigInteger, Murl.Math.BigInteger Divide(Murl.Math.BigInteger other, Murl.Math.BigInteger remainder)

Parameters
otherThe big-integer object to divide.
remainderThe remainder return value.
Returns
Murl.Math.BigInteger The divided big-integer object.
Murl.Math.BigInteger remainder The remainder return value.

Modulo(other)

Divide this by a big-integer object and return the remainder.

Murl.Math.BigInteger Modulo(Murl.Math.BigInteger other)

Parameters
otherThe big-integer object to divide.
Returns
Murl.Math.BigInteger The remainder big-integer object.

Power(n)

Get this raised to the power of an integer exponent.

Murl.Math.BigInteger Power(Integer n)

Parameters
nThe integer exponent.
Returns
Murl.Math.BigInteger The exponentiated big-integer object.

Power(n)

Get this raised to the power of a big-integer exponent.

Murl.Math.BigInteger Power(Murl.Math.BigInteger n)

Parameters
nThe big-integer exponent.
Returns
Murl.Math.BigInteger The exponentiated big-integer object.

PowerModulo(n, m)

Divide this raised to the power of a big-integer exponent by a big-integer object and return the remainder.

Murl.Math.BigInteger PowerModulo(Murl.Math.BigInteger n, Murl.Math.BigInteger m)

Parameters
nThe big-integer exponent.
mThe big-integer object to divide.
Returns
Murl.Math.BigInteger The remainder big-integer object.

GreatestCommonDivisor(other)

Get the greatest common divisor of this.

Murl.Math.BigInteger GreatestCommonDivisor(Murl.Math.BigInteger other)

Parameters
otherThe big-integer object to divide.
Returns
Murl.Math.BigInteger Get the greatest common divisor of this.

InvertSelf()

Invert the big-integer value.

InvertSelf()


AbsSelf()

Make the big-integer value absolute.

AbsSelf()


MoveBytesLeftSelf(bytes)

Move left the bytes of the value.

MoveBytesLeftSelf(Integer bytes)

Parameters
bytesThe number of bytes to move.

MoveBytesRightSelf(bytes)

Move right the bytes of the value.

MoveBytesRightSelf(Integer bytes)

Parameters
bytesThe number of bytes to move.

AddSelf(other)

Add a big-integer object to this.

AddSelf(Murl.Math.BigInteger other)

Parameters
otherThe big-integer object to add.

SubtractSelf(other)

Subtract a big-integer object to this.

SubtractSelf(Murl.Math.BigInteger other)

Parameters
otherThe big-integer object to subtract.

MultiplySelf(other)

Multiply this by a big-integer object.

MultiplySelf(Murl.Math.BigInteger other)

Parameters
otherThe big-integer object to multiply.

DivideSelf(other)

Divide this by a big-integer object.

DivideSelf(Murl.Math.BigInteger other)

Parameters
otherThe big-integer object to divide.

DivideSelf(other, remainder)

Divide this by a big-integer object.

Murl.Math.BigInteger DivideSelf(Murl.Math.BigInteger other, Murl.Math.BigInteger remainder)

Parameters
otherThe big-integer object to divide.
remainderThe remainder return value.
Returns
Murl.Math.BigInteger remainder The remainder return value.

ModuloSelf(other)

Divide this by a big-integer object and store the remainder.

ModuloSelf(Murl.Math.BigInteger other)

Parameters
otherThe big-integer object to divide.

PowerSelf(n)

Raise this to the power of an integer exponent.

PowerSelf(Integer n)

Parameters
nThe integer exponent.

PowerSelf(n)

Raise this to the power of a big-integer exponent.

PowerSelf(Murl.Math.BigInteger n)

Parameters
nThe big-integer exponent.

PowerModuloSelf(n, m)

Divide this raised to the power of a big-integer exponent by a big-integer object and store the remainder.

PowerModuloSelf(Murl.Math.BigInteger n, Murl.Math.BigInteger m)

Parameters
nThe big-integer exponent.
mThe big-integer object to divide.

ToHexString()

Get the Hex character string of the value.

String ToHexString()

Returns
String The Hex character string of the value.

ToData(length)

Get the data object of the value. Stores the value bytes to a data object:

  • The first byte is the most significant byte.
  • The last byte is the least significant byte.
  • The sign is not stored.

Murl.Data ToData(Integer length)

Parameters
lengthThe 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.
Returns
Murl.Data The the data object of the value.

ToUInt32(start, count)

Get the 32 bit unsigned integer value.

Integer ToUInt32(Integer start, Integer count)

Parameters
startThe index of the byte to start in range [0 .. GetLength() - 1].
countThe number of bytes to get.
Returns
Integer The 32 bit unsigned integer value.

ToUInt64(start, count)

Get the 64 bit unsigned integer value.

Integer ToUInt64(Integer start, Integer count)

Parameters
startThe index of the byte to start in range [0 .. GetLength() - 1].
countThe number of bytes to get.
Returns
Integer The 64 bit unsigned integer value.


Metamethods


The equal to operator.

Equal to comparison operator.

Returns
Boolean = Murl.Math.BigInteger == Murl.Math.BigInteger

The less than operator.

Less than operator.

Returns
Boolean = Murl.Math.BigInteger < Murl.Math.BigInteger

The less than or equal operator.

Less than or equal to operator.

Returns
Boolean = Murl.Math.BigInteger <= Murl.Math.BigInteger

The addition operator.

Addition operator.

Returns
Murl.Math.BigInteger = Murl.Math.BigInteger + Murl.Math.BigInteger

The unary minus operator.

Unary minus operator.

Returns
Murl.Math.BigInteger = - Murl.Math.BigInteger

The subtraction operator.

Subtraction operator.

Returns
Murl.Math.BigInteger = Murl.Math.BigInteger - Murl.Math.BigInteger

The multiplication operator.

Multiplication operator.

Returns
Murl.Math.BigInteger = Murl.Math.BigInteger * Murl.Math.BigInteger

The division operator.

Division operator.

Returns
Murl.Math.BigInteger = Murl.Math.BigInteger / Murl.Math.BigInteger

The modulo operator.

Modulo operator.

Returns
Murl.Math.BigInteger = Murl.Math.BigInteger % Murl.Math.BigInteger