[R] Integer bit size and the modulus operator
Liaw, Andy
andy_liaw at merck.com
Mon Jan 30 19:39:07 CET 2006
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 tool for the purpose.
Andy
From: 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
> exceed this about 8^19.
>
> > a=1:40;
> > 8^a %% 41
> [1] 8 23 20 37 9 31 2 16 5 40 33 18 21 4 32 10 39 25 36
> 1 8 23 20
> 37 9 31 2 16 5 40 33
> [32] 18 21 4 32 10 0 0 0 0
> There were 21 warnings (use warnings() to see them)
> > warnings()
> Warning messages:
> 1: probable complete loss of accuracy in modulus
> 2: probable complete loss of accuracy in modulus
> 3: probable complete loss of accuracy in modulus
> 4: probable complete loss of accuracy in modulus
> 5: probable complete loss of accuracy in modulus
> 6: probable complete loss of accuracy in modulus
> 7: probable complete loss of accuracy in modulus
> 8: probable complete loss of accuracy in modulus
> 9: probable complete loss of accuracy in modulus
> 10: probable complete loss of accuracy in modulus
> 11: probable complete loss of accuracy in modulus
> 12: probable complete loss of accuracy in modulus
> 13: probable complete loss of accuracy in modulus
> 14: probable complete loss of accuracy in modulus
> 15: probable complete loss of accuracy in modulus
> 16: probable complete loss of accuracy in modulus
> 17: probable complete loss of accuracy in modulus
> 18: probable complete loss of accuracy in modulus
> 19: probable complete loss of accuracy in modulus
> 20: probable complete loss of accuracy in modulus
> 21: probable complete loss of accuracy in modulus
> >
> > 8^35
> [1] 4.056482e+31
> > 8^36
> [1] 3.245186e+32
> > 8^19
> [1] 1.441152e+17
> > 8^19%%41
> [1] 36
> > 8^20
> [1] 1.152922e+18
> > 8^20%%41
> [1] 1
> Warning message:
> probable complete loss of accuracy in modulus
> >
>
>
>
> On 1/30/06, Ionut Florescu <ifloresc at 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 at 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 at 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
>
>
More information about the R-help
mailing list