Thread: MOD
View Single Post
  #16   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dana Dana is offline
external usenet poster
 
Posts: 3
Default MOD


Unfortunately, I have to deal with numbers more than 15 digits (such as 17
digits). Does it mean that I have no ways to manage such problems (if the
number is more than 15 digits)?



Hi. Don't know what you have set up, so this is real general...
Suppose you had the following text number with 21 digits in A1.
'123456789012345678901

=MyMod(A1,7)
returns the correct answer of 4.

Function MyMod(n, m)
MyMod = (CDec(n) - m * Int(CDec(n) / m))
End Function

Again, very general, but may give you some ideas if you do in fact
have numbers as text over 15 digits.

HTH
Dana DeLouis


On Tue, 3 Oct 2006 07:31:02 -0700, J.H.
wrote:

Thank you for your method here.

Unfortunately, I have to deal with numbers more than 15 digits (such as 17
digits). Does it mean that I have no ways to manage such problems (if the
number is more than 15 digits)?

Thanks for your concern.



“vezerid”???

Hmmmm,
now I understand the meaning of the second message in the thread. Well,
this is news to me too! On the other hand, the following formula:

=A1-FLOOR(A1,2)

will return the same as MOD(A1,2) and it does not suffer from this
problem, although it would be good only for positive numbers in A1.

Microsoft suggest another identity, which I am sure will also work:

MOD(n, d) = n - d*INT(n/d)

HTH
Kostis

Pete_UK wrote:
Kostis,

that's what I thought and tried it - MOD(123456789,2) returns 1 as
expected, but MOD(1234567890,2) returns #NUM!, even if the number is in
a different cell.

I haven't come across this before.

Pete

vezerid wrote:
The number of digits should not be a problem. Excel supports up to 15
digits of precision and it will accept longer representations even if
it truncates their precision to 15 digits.

On the other hand, using a number literal as formatted (i.e. with the
commas as thousand separator) WILL cause an error because commas are
confused with the argument separator.

Try entering the number in a different cell (say A1) and then using
=MOD(A1,something). You should not get an error.

HTH
Kostis Vezerides


J.H. wrote:
I have a question on the funtion "MOD". When the number to be divided is more
than nine digits (like: 1,234,457,890), the funtion would return error. How
can I fix this?

Thanks.