Re: [R] Integer bit size and the modulus operator

From: Duncan Murdoch <>
Date: Tue 31 Jan 2006 - 05:28:37 EST

On 1/30/2006 11:32 AM, Ionut Florescu wrote:
> I am a statistician and I come up to an interesting problem in
> cryptography. I would like to use R since there are some statistical
> procedures that I need to use.
> However, I run into a problem when using the modulus operator %%.
> I am using R 2.2.1 and when I calculate modulus for large numbers (that
> I need with my problem) R gives me warnings. For instance if one does:
> a=1:40;
> 8^a %% 41
> one obtains zeros which is not possible since 8 to any power is not a
> multiple of 41.
> In addition when working with numbers larger that this and with the mod
> operator R crashes randomly.

Could you keep a record of the random crashes, and see if you can make any of them repeatable? R shouldn't crash. If you can find a repeatable way to make it crash, then that's a bug that needs to be fixed. (If it crashes at random it should still be fixed, but it's so much harder to fix that it's unlikely to happen unless the cases are ones that look likely to come up in normal situations.)

> I believe this is because R stores large integers as real numbers thus
> there may be lack of accuracy when applying the modulus operator and
> converting back to integers.
> So my question is this: Is it possible to increase the size of memory
> used for storing integers? Say from 32 bits to 512 bits (Typical size of
> integers in cryptography).

No, but there is at least one contributed package that does multiple precision integer arithmetic. I can't remember the name of it right now, but Google should be able to find it for you...

Duncan Murdoch
> Thank you, any help would be greatly appreciated.
> Ionut Florescu
> ______________________________________________
> mailing list
> PLEASE do read the posting guide! mailing list PLEASE do read the posting guide! Received on Tue Jan 31 05:45:07 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:15 EST