Thread: Truncate/Mod
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Truncate/Mod

Help says for Mod

The modulus, or remainder, operator divides number1 by number2 (rounding
floating-point numbers to integers)

so it indeed only works on integers.

Integers can do 32k, but Longs will cover -2,147,483,648 to 2,147,483,647.

INT is the equivalent of TRUNC - INT(7.6) is 7

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Abode" wrote in message
...
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.