## Large integer numbers in Xojo

In the class we provide functions to convert from/to Xojo data types and can convert number to/from strings. We provide common functions to calculate with the large numbers, so add, subtract, multiply and divide work. We also provide modulo and a combined divide and modulo operation. You can shift bitwise left and right and do bitwise AND and OR operations. We even provide convenient functions for square and square root.

The operators are overloaded for Xojo, so you can just use the numbers like others. If you pass nil for a parameter, we take it as 0 automatically. For your convenience, the numbers convert automatically to/from string, so you can pass them directly to a msgbox.

Here is a sample code snippet, which shows that we can do math with more than 64bit to avoid an overflow with really big numbers multiplied and divided:

Dim n1 As Int64 = 10000000000
Dim n2 As Int64 = 10000000000
Dim n3 As Int64 = n1 * n2 // overflow, so wrong result
Dim n4 As Int64 = n3 / n2
Dim l1 As LargeNumberMBS = LargeNumberMBS.NumberWithInt64(n1)
Dim l2 As LargeNumberMBS = LargeNumberMBS.NumberWithInt64(n2)
Dim l3 As LargeNumberMBS = l1 * l2
Dim l4 As LargeNumberMBS = l3 / l1
Dim s4 As String = l4.StringValue // this is correct
Break

Please try this with next prerelease. Please do not hesitate to contact us with questions.