2006/7/16, Andy Pepperdine <[EMAIL PROTECTED]>:
On Sunday 16 July 2006 06:48, Andrius Aštrauskas wrote:
> On Fri, 14 Jul 2006 13:32:45 +0200
>
> Jurgen Stigter <[EMAIL PROTECTED]> wrote:
> > /I am using version 2.0 of OpenOffice.org. My problem is :/
> >
> > The MOD function is returning -512 instead of 0 (though each of the
> > factors is divisable by 23):
> > MOD (9951585559 *370469809;23) results in -512, but when I copy the
> > formula and put it in another cell, the result is -320
> > while
> > MOD (9951585559;23) results in 0
> > MOD (370469809;23) results 0
This is almost certainly due to an integer overflow. There will be a limit to
the size of exact integer values. I don't know how big they can be; perhaps
someone else can say.
log2 (9951585559) => 33.21 bits
log2(370469809) => 28.46 bits
The product needs 61.68 bits, less than 63 (one taken by the sign).
I.e. 64 bit arithmetics ought to work.
both MOD (9951585559 *370469809;23) and MOD ((9951585559
*370469809)-1;23) gives the result 0 for me (XP, OOO 2.03), implying
overflow. But why?
MOD (9951585559-1;23) gives 22, so it works for more than 32 bits.
Are the integers handled as float numbers when they are big enough?
9951585559 *370469809 is displayed as 3,69E+018, implying this and
making sense to the result.
In this particular case, you can rewrite the formula because:
a*b (mod p) = a (mod p) * b (mod p)
Not really. Max(a*b (mod p))=p-1; Max(a (mod p) * b (mod p))=(p-1)**2.
(a (mod p) * b (mod p)) (mod p) might work.
/$
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]