Right now building and testing the program I am modeling this...

1.9923E+130 by 17947.

I keep getting a variable overflow message.

Hi. If you are trying to do large Mod's with Excel, here is a very

general

technique mentioned by Harlan Grove using vba.

First off, Excel's vba's MOD function will probably not work. However,

we

can use your Mod function as a workaround.

Reference:

XL: MOD() Function Returns #NUM! Error Value

http://support.microsoft.com/default.aspx?scid=kb;en-us;119083
It's probably easier to use a math program for this demo, but it should

be

easy to follow.

Let's scale the problem down to fit here. You should be able to adjust

it

for your own larger numbers.

Our two numbers...

n = 199230000000000000000000000000;

m = 17947;

We are trying to use Excel to find this...

Mod[n, m]

13321

So for now, we know the answer to be 13321.

= = = = = = = = = = = = = = = = = = = = = = = =

First, break the large number down into manageable sizes. We'll use a

size

of 6. i.e. Place each group of 6 numbers into an array.

199230-000000-000000-000000-000000

To add 6 zero's to a number, multiply by 1000000.

Scale = 1000000;

Our first manageable Mod operation:

Mod[199230, m]

1813

Now loop 4 times.

Take previous answer, and append the next 6 numbers.

Mod[1813*Scale, m]

12007

Mod[12007*Scale, m]

8325

Mod[8325*Scale, m]

14845

Our last loop should give us our answer.

Mod[14845*Scale, m]

13321

Which it does. :>)

--

HTH. :>)

Dana DeLouis

Windows XP, Office 2003

I've been working on this for the good portion of today and Im very

baffled.

I'm probably overlooking something very simple. Anyway I need to get

the

mod

of some very very large numbers. So large I need to split it down into

smaller componants just to load it into a double (Im doing this all for

fun.

I just really want to figure this out because there must be a way).

Anyway,

so I've split the number into a much smaller number 1.9923E+130

approximately. I need to mod this number by a variable that can reach

well

into the 60,000s. Unfortunately as far as I can tell the Mod operator

is

only capable of returning an integer. I believe integers can only go

up

to

16k or 32k.

Right now building and testing the program Im modding this 1.9923E+130

by

17947. I keep getting a variable overflow message. I've attempted to

write

my own Mod function which needed its own Truncate function (Does VBA

even

that the ability to truncate?!). It works find on smaller numbers.

Something well into the quintillians I believe. But when it faces by

1.9923E+130 my truncate function returns a 1. Okay, well my truncate

function is probably doing it all wrong. Its basically:

Arr = Split(number, "."

trunc = Arr(0)

My Mod function is something along the lines of:

number = number / divisor

TruncNum = trunc(number)

fMod = (number - TruncNum) * divisor

So if anyone has any suggestions or sollutions please let me know. If

pursuing this little project of mine is just rediculous please let me

know

too. I've been having fun thusfar minus the arteries which may have

ruptured

in my head. Blah.