Why do I get an overflow error while doing 055755241763 Mod 94?
It is being output to a variable that is of type double...
Printable View
Why do I get an overflow error while doing 055755241763 Mod 94?
It is being output to a variable that is of type double...
Probably because 055755241763 is simply too big for the Mod.
Then whats the max number for mod? Is there any war around this?
After a bit of experimenting, the max number is 999999999 (9 chars long). Anything above that causes the overflow. I can't think of anyway way round it. Even if you took only a quarter of that number it would still be 11 chars long.
Create your own mod operator by seeing if:
number/interval = int(number/interval) then 0 else get remainder
Function Modular(Num1, Num2)
Divided = Num1 / Num2
If Divided = Int(Divided) Then
Modular = 0
Else
FractionPart = Divided - Int(Divided)
Modular = FractionPart * Num2
End If
End Function
Code:Function NuMod(ByVal x As Double, y As Double) As Double
'Nucleus
x = CInt(x): y = CInt(y) 'round floating point numbers To integers
If x / y = CInt(x / y) Then NuMod = 0 Else NuMod = x - Int(x / y) * y
End Function