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

From: jim holtman <jholtman_at_gmail.com>
Date: Tue 31 Jan 2006 - 05:59:28 EST

The other thing that you have to be aware of is that 8^n is not 8 multiplied by itself n times. You are probably using logs to compute this. Here is a sample of 8^(1:20). The value of 8^2 is 64.000000000000004 (not exactly an integer); roundoff errors are apparent in the other values.

> 8^(1:20)

 [1] 8.0000000000000000e+00 6.4000000000000004e+01 5.1200000000000001e+02
4.0960000000000001e+03
 [5] 3.2768000000000002e+04 2.6214400000000002e+05 2.0971519999999999e+06 1.6777215999999999e+07
 [9] 1.3421772800000000e+08 1.0737418240000001e+09 8.5899345920000005e+09 6.8719476736000003e+10
[13] 5.4975581388799997e+11 4.3980465111039999e+12 3.5184372088832001e+13 2.8147497671065600e+14
[17] 2.2517998136852482e+15 1.8014398509481984e+16 1.4411518807585588e+17 1.1529215046068471e+18
>

On 1/30/06, Ionut Florescu <ifloresc@stevens.edu> 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.
>
> 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).
>
> Thank you, any help would be greatly appreciated.
> Ionut Florescu
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>

--
Jim Holtman
Cincinnati, OH
+1 513 247 0281

What the problem you are trying to solve?

	[[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Tue Jan 31 06:25:58 2006

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