[R] long integer handling

Yousri Fanous you@r|@|@nou@ @end|ng |rom gm@||@com
Sat Nov 14 18:41:48 CET 2020


Thank you!

On Sat, Nov 14, 2020 at 12:54 AM Rui Barradas <ruipbarradas using sapo.pt> wrote:

> Hello,
>
> I forgot to suggest package gmp. See the second example in
>
> ?gmp::bigz
>
> Hope this helps,
>
> Rui Barradas
>
> Às 05:50 de 14/11/20, Rui Barradas escreveu:
> > Hello,
> >
> > You can compute the exact result with package Rmpfr.
> > See ?mpfr and [1].
> >
> >
> > library(Rmpfr)
> >
> > two <- mpfr(2, precBits = 64)
> > two^64 - 1
> > #1 'mpfr' number of precision  64   bits
> > #[1] 18446744073709551615
> >
> >
> >
> > [1] https://www.mpfr.org/
> >
> > Hope this helps,
> >
> > Rui Barradas
> >
> > Às 01:44 de 14/11/20, Yousri Fanous escreveu:
> >> I want to calculate 2^64-1 which is
> >> 18446744073709551615
> >>
> >> I set the following options to prevent scientific notation
> >> options("scipen"=100, "digits"=4)
> >>> x<-2^64 -1
> >>> x
> >> [1] 18446744073709551616
> >>
> >> This is not correct. There seem to be still some approximation
> happening.
> >> How can I get the correct result?
> >>
> >> Yousri
> >> IBM Canada ltd
> >> Software developer
> >>
> >>     [[alternative HTML version deleted]]
> >>
> >> ______________________________________________
> >> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> > ______________________________________________
> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list