I need to perform a module operation on very large integers. The largest integer supported by my platform (edit: .NET 2.0) is a 64-bit integer that is not large enough for the numbers I'm working with.
How can I make a module on really large integers, for example 12654875632126424875387321657498462167853687516876876?
I have a solution that treats a number as a string and processes it piecemeal one by one, but I wanted to know if there is a better way.
Here, my function treats the number as a string. This basically makes a long split the way you did it manually.
Public Function MyMod(ByVal numberString As String, ByVal modby As Integer) As Integer
Dim position As Integer = -1
Dim curSubtraction As Integer = 0
While position < numberString.Length - 1
position += 1
curSubtraction = curSubtraction * 10 + CInt(numberString.Substring(position, 1))
If (curSubtraction / modby) < 1 And position = numberString.Length - 1 Then
Return curSubtraction
ElseIf (curSubtraction / modby) < 1 Then
Continue While
Else
curSubtraction = curSubtraction Mod modby
End If
End While
Return curSubtraction
End Function
Is there a cleaner, more efficient way?
EDIT: , IBAN. , IBAN ( ) . . , , , on - .