[R] Integer bit size and the modulus operator

2006-01-30 Thread Ionut Florescu
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

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

2006-01-30 Thread jim holtman
You have reached the maximum value that can be stored accurately in a floating point number. That is what the error message is telling you. I get 21 warnings and this says that at 8^20 I am now truncating digits in the variable. You only have about 54 bits in the floating point number and you

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

2006-01-30 Thread Duncan Murdoch
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

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

2006-01-30 Thread Liaw, Andy
R is probably not the best tool for handling large integers... AFAIK Python has the interesting feature of not only having a `long' integer type (that can store arbitrarily large integers), but can convert a regular 4-byte int to the `long' type when necessary. Perhaps that would be a better

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

2006-01-30 Thread Ionut Florescu
Thank you for the quick reply, I will look into the R packages. For crashing R try this: generator.zp=function(x,p) {a=1:(p-1); b=x^a%%p; if(all(b[1:(p-2)]!=1)(b[p-1]==1)){return(x, Good )} else{return(x, No Good, try another integer )} } This checks if element x is a generator of the group

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

2006-01-30 Thread Duncan Murdoch
On 1/30/2006 1:39 PM, Ionut Florescu wrote: Thank you for the quick reply, I will look into the R packages. For crashing R try this: generator.zp=function(x,p) {a=1:(p-1); b=x^a%%p; if(all(b[1:(p-2)]!=1)(b[p-1]==1)){return(x, Good )} else{return(x, No Good, try another integer )} }

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

2006-01-30 Thread jim holtman
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.004 (not exactly an integer); roundoff errors are apparent in the other values. 8^(1:20)

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

2006-01-30 Thread Prof Brian Ripley
This is a double protection error in real_binary. See the R-devel list for the details. Now fixed. On Mon, 30 Jan 2006, Ionut Florescu wrote: Thank you for the quick reply, I will look into the R packages. For crashing R try this: generator.zp=function(x,p) {a=1:(p-1); b=x^a%%p;

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

2006-01-30 Thread Ionut Florescu
Thank you, I didn't notice that. I may have to come up with my own power function as well, slower but precise. jim holtman wrote: 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

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

2006-01-30 Thread Peter Dalgaard
jim holtman [EMAIL PROTECTED] writes: 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.004 (not exactly an integer); roundoff errors

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

2006-01-30 Thread Ionut Florescu
Actually it does that in my 2.2.1 version as well: options(digits=20) 8^(1:20) [1] 8.e+00 6.4004e+01 5.1201e+02 [4] 4.0961e+03 3.27680002e+04 2.62144002e+05 [7] 2.09715199e+06 1.67772159e+07

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

2006-01-30 Thread Peter Dalgaard
Ionut Florescu [EMAIL PROTECTED] writes: Actually it does that in my 2.2.1 version as well: options(digits=20) 8^(1:20) [1] 8.e+00 6.4004e+01 5.1201e+02 [4] 4.0961e+03 3.27680002e+04 2.62144002e+05 [7]

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

2006-01-30 Thread Prof Brian Ripley
On Mon, 30 Jan 2006, Peter Dalgaard wrote: Ionut Florescu [EMAIL PROTECTED] writes: Actually it does that in my 2.2.1 version as well: options(digits=20) 8^(1:20) [1] 8.e+00 6.4004e+01 5.1201e+02 [4] 4.0961e+03 3.27680002e+04