Dana DeLouis wrote...
....
>I used Int since you are doing Mod 97, and it shouldn't make a difference.
>A higher Mod requires a few more steps. I mention this as the use of Int( )
>will revert back to double.
>
>Sub Demo()
> Dim n
> Dim R As Long
> n = CDec("210005665660111000") / 97
> R = (n - Int(n)) * 97
>
> Debug.Print n
> Debug.Print R
>End Sub
>
>Returns:
> 2165006862475371.1340206185567
> 13
>
>Which checks with another program:
>Mod[210005665660111000, 97]
>13
....
Personally, I prefer divide & conquer (pun intended), and for division
the best d&c algorithm is long division. If there are 18 decimal
numberals in the numeric string, the remainder when dividing by 97 is
given by
=MOD(MOD(MOD(MID(s,1,6),97)&MID(s,7,6),97)&MID(s,13,6),97)
Elementary school long division uses one numeral at a time, but it's
not necessary. It's reasonably efficient to use 3 chunks of 6 numerals
each. Note that using 2 chunks of 9 numerals each can bump into the bug
in Excel's MOD function
(
http://support.microsoft.com/default...b;en-us;119083).
FTHOI, the quotient is given by
=INT(MID(s,1,6)/97)&TEXT(INT((MOD(MID(s,1,6),97)&MID(s,7,6))/97),"000000")
&TEXT(INT((MOD(MOD(MID(s,1,6),97)&MID(s,7,6),97)&MID(s,13,6))/97),"000000")
and the full result could be given by
=INT(MID(s,1,6)/97)&TEXT(INT((MOD(MID(s,1,6),97)&MID(s,7,6))/97),"000000")
&TEXT(INT((MOD(MOD(MID(s,1,6),97)&MID(s,7,6),97)&MID(s,13,6))/97),"000000")
&TEXT(MOD(MOD(MOD(MID(s,1,6),97)&MID(s,7,6),97)&MID(s,13,6),97)/97,
".000000000000000")
which returns
2165006862475371.134020618556701
Who says Excel can't handle more than 15 decimal digits?!