-
I'm writing a routine which requires the handling of large numbers.
I've declared all my variables as Variant and I use CDec where required.
However, I get an Overflow Error (6) when I use the MOD operator.It seems to be restricted to Long data-types.
Is there an equivalent I can use, or am i using it incorrectly?
Thanks,
Jim
-
What size numbers are you using?
Using Variants is usually a bad idea
-
-
VERY large numbers!
I've had to use variants in order to use the Decimal sub-type - that's how big they are.
In the order of 1,000,000,000,000,000,000,000
The help file doesn't indicate that MOD is restricted to the LONG range, but that would appear to be the case.
Any APIs?....
-
jimwillsher is working on a "bank account" calculator for me :D
-
Sorted it!
Looks like the MOD calculator is limited to the LONG range, but the INT operator is not.
Changed logic to use
Dim Whole as Variant
Whole = CDec(Int(Long_Number / Divisor))
Remainder = Long_number - (Whole * Divisor)
Seems to work fine now - handles the full range of DECIMAL numbers.
(For reference, I'm writing a base-conversion utility and need to be able to handle extremely long hex numbers. My numbers ar enot restricted to just Hex, therefore I can;t use any of the built-in functions.)