Platforms to show: All Mac Windows Linux Cross-Platform

Back to LargeNumberMBS class.

LargeNumberMBS.Add(other as LargeNumberMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Adds other number.

See also:

LargeNumberMBS.Add(other as LargeNumberMBS) as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Adds other number and returns result.

See also:

LargeNumberMBS.AddMod(v as LargeNumberMBS, Modulo as LargeNumberMBS) as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Addition with modulo.
Example
Var v As New LargeNumberMBS(100)
Var o As New LargeNumberMBS(200)
Var n As New LargeNumberMBS(&hFF)

Var r As LargeNumberMBS = v.AddMod(o, n)

MsgBox r.StringValue // shows 45 = (100+200) mod 255

LargeNumberMBS.CheckBit(bit as integer) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Checks whether a bit is set.

Returns true if bit is set.

LargeNumberMBS.Clone as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a copy of the number.

LargeNumberMBS.Constructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a new instance with value zero.
Example
Var l1 As New LargeNumberMBS
MsgBox l1.StringValue

See also:

LargeNumberMBS.Constructor(other as LargeNumberMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a copy of the number.
Example
Var l1 As New LargeNumberMBS(123456789)
Var l2 As New LargeNumberMBS(l1)

MsgBox l2.StringValue

See also:

LargeNumberMBS.Constructor(value as Int32)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a new instance with an 32-bit integer.

See also:

LargeNumberMBS.Constructor(value as Int64)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a new instance with an 64-bit integer.

See also:

LargeNumberMBS.Constructor(value as String)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a new number based on a string.

Raises OutOfBoundsExceptionMBS if your string is too long.

See also:

LargeNumberMBS.Constructor(value as UInt32)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a new instance with an unsigned 32-bit integer.

See also:

LargeNumberMBS.Constructor(value as UInt64)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a new instance with an unsigned 64-bit integer.

See also:

LargeNumberMBS.Decrement(value as UInt32 = 1)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Decrement number with an integer.
Example
Var o As New LargeNumberMBS(5)
MsgBox o.StringValue
o.Increment
MsgBox o.StringValue
o.Decrement
MsgBox o.StringValue

This is faster than building a new LargeNumberMBS, just to subtract some small number.

LargeNumberMBS.Divide(other as LargeNumberMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Divides value with by value.

See also:

LargeNumberMBS.Divide(other as LargeNumberMBS) as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Divides value with by value.

See also:

LargeNumberMBS.Divide(value as UInt32) as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Divide by given integer and return result.
Example
Var o As New LargeNumberMBS(63)
Var r1 As LargeNumberMBS = o.Divide(8)
Var r2 As UInt32 = o.Modulo(8)

MsgBox r1.StringValue+" "+str(r2) // shows 7 and 7

For small numbers this is more efficient than creating new LargeNumberMBS to store value.

See also:

LargeNumberMBS.DivMod(other as LargeNumberMBS, byref DivResult as LargeNumberMBS, byref ModResult as LargeNumberMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Performs divide and modulo together.
Example
Var d As New LargeNumberMBS(100)
Var n As New LargeNumberMBS(13)

Var x As LargeNumberMBS
Var y As LargeNumberMBS

d.DivMod n, x, y

MsgBox d.StringValue + " = " + x.StringValue + " * " + n.StringValue + " + " + y.StringValue

Puts result into both byref parameters.

LargeNumberMBS.Equals(other as LargeNumberMBS) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Compares if two numbers are equal.

Returns true if equal.

LargeNumberMBS.ExpMod(e as LargeNumberMBS, Modulo as LargeNumberMBS) as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Calculates an exponent.
Example
Var o As New LargeNumberMBS(2)
Var e As New LargeNumberMBS(11)
Var m As New LargeNumberMBS(255)
Var r As LargeNumberMBS = o.ExpMod(e,m)

MsgBox r.StringValue // shows 8 = 2^11 mod 255

Returns x^e mod n where x is the current number, e a parameter and n the modulo parameter.

LargeNumberMBS.FindGCD(v as LargeNumberMBS) as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Finds greatest common divisor for two positive numbers.

Some examples using this method:

LargeNumberMBS.GetStringValue(Base as Integer = 10, ThousandsDelimiter as String = "") as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Queries number with a given base and delimiter.
Example
Var l As New LargeNumberMBS(1234567890)

Var s0 As String = l.StringValue
Var s1 As String = l.GetStringValue
// 1234567890
Var s2 As String = l.GetStringValue(10, ",")
// 1,234,567,890
Var s4 As String = l.GetStringValue(8, "")
// 499602d2
Var s3 As String = l.GetStringValue(16, "")
// 11145401322

Break // check in debugger

With all default parameter, this is same as StringValue property.

LargeNumberMBS.Increment(value as UInt32 = 1)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Increment number with an integer.
Example
Var o As New LargeNumberMBS(5)
MsgBox o.StringValue
o.Increment
MsgBox o.StringValue
o.Decrement
MsgBox o.StringValue

This is faster than building a new LargeNumberMBS, just to add some small number.

LargeNumberMBS.IsPrime(iter as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Checks if number is a prime number.
Example
Var lines() As String

For i As Integer = 61 To 69 Step 2
Var a As New LargeNumberMBS(i)
lines.Append a.StringValue+": "+Str(a.IsPrime(5))
Next

MsgBox Join(lines, EndOfLine)

Returns 1 if prime and 0 if not.
Returns -1 in case of error.

Iter is the factor between 1 and 680 about how deep to iterate. The bigger the this factor, the more exact the check is.

Miller-Rabin Algorithm (ret=1 .. n is composit)

LargeNumberMBS.LeftShift(bits as integer) as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Shifts value to left by given number of bits.

Bits must be <= 32.

LargeNumberMBS.ModInverse(Modulo as LargeNumberMBS) as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
This function calculates modular multiplicative inverse of an given integer a modulo m.
Example
Var l As New LargeNumberMBS(3)
Var n As New LargeNumberMBS(26)

Var r As LargeNumberMBS = l.ModInverse(n)

MsgBox r.StringValue

LargeNumberMBS.Modulo(other as LargeNumberMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Modulo value.

Divides value and returns the rest.

See also:

Some examples using this method:

LargeNumberMBS.Modulo(other as LargeNumberMBS) as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Modulo value.

Divides value and returns the rest.

See also:

LargeNumberMBS.Modulo(value as UInt32) as UInt32

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Divide by given integer and return remainder.
Example
Var o As New LargeNumberMBS(63)
Var r1 As LargeNumberMBS = o.Divide(8)
Var r2 As UInt32 = o.Modulo(8)

MsgBox r1.StringValue+" "+str(r2) // shows 7 and 7

For small numbers this is more efficient than creating new LargeNumberMBS to store value.

See also:

LargeNumberMBS.MulMod(v as LargeNumberMBS, Modulo as LargeNumberMBS) as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Multiply with modulo.
Example
Var o As New LargeNumberMBS(50)
Var f As New LargeNumberMBS(80)
Var m As New LargeNumberMBS(255)
Var r As LargeNumberMBS = o.MulMod(f, m)

MsgBox r.StringValue // shows 175 = (50 * 80) mod 255

LargeNumberMBS.Multiply(other as LargeNumberMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Multiplies value with other value.

See also:

LargeNumberMBS.Multiply(value as UInt32) as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Multiply by given integer and return result.
Example
Var o As New LargeNumberMBS(5)
Var r As LargeNumberMBS = o.Multiply(8)

MsgBox r.StringValue // shows 40

For small numbers this is more efficient than creating new LargeNumberMBS to store value.

See also:

LargeNumberMBS.Negate as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Negates the value.

Returns new value with different sign.

LargeNumberMBS.RightShift(bits as integer) as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Shifts value to right by given number of bits.

Bits must be <= 32.

LargeNumberMBS.SetStringValue(Text As String, Base as Integer, byref AfterText as String, Byref ValueRead as boolean)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets number from text.

Returns the text after the given text following the number in AfterText parameter.
Sets ValueRead if a value was read.

LargeNumberMBS.SetZero

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets number to zero.
Example
Var l1 As LargeNumberMBS = LargeNumberMBS.NumberWithInt32(12345)
MsgBox l1.StringValue

// set to zero
l1.SetZero
MsgBox l1.StringValue

LargeNumberMBS.SqrMod(Modulo as LargeNumberMBS) as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Multiply with itself and modulo.
Example
Var o As New LargeNumberMBS(90)
Var m As New LargeNumberMBS(255)
Var r As LargeNumberMBS = o.SqrMod(m)

MsgBox r.StringValue // shows 195 = (90 * 90) mod 255

LargeNumberMBS.sqrt as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Calculates square root of value.
Example
Var l As New LargeNumberMBS(1234567890123456)

// let's multiple first and then
Var q As LargeNumberMBS = l * l
Var root As LargeNumberMBS = q.Sqrt

If l = root Then
Break // okay
Else
Break // failed
End If

Get nearly square root of a. The answer will be a >= ret^2.

LargeNumberMBS.Square as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Calculates square of current value.

Return x^2.

LargeNumberMBS.SubMod(v as LargeNumberMBS, Modulo as LargeNumberMBS) as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Subtraction with modulo.
Example
Var v As New LargeNumberMBS(100)
Var o As New LargeNumberMBS(200)
Var n As New LargeNumberMBS(&hFF)

Var r As LargeNumberMBS = v.SubMod(o, n)

MsgBox r.StringValue // shows 155 = (100-200) mod 255

// -100 is too small, so 255 is added to bring to range.

LargeNumberMBS.Subtract(other as LargeNumberMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Subtracts other number.

See also:

LargeNumberMBS.Subtract(other as LargeNumberMBS) as LargeNumberMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Math MBS DataTypes Plugin 19.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Subtracts other number and returns result.

See also:

The items on this page are in the following plugins: MBS DataTypes Plugin.


The biggest plugin in space...