[Rd] large integer values

Martyn Plummer plummerm at iarc.fr
Wed May 14 17:24:12 CEST 2014


On Wed, 2014-05-14 at 18:17 +0300, Adrian Dușa wrote:
> On Wed, May 14, 2014 at 5:35 PM, Simon Urbanek
> <simon.urbanek at r-project.org>wrote:
> 
> > [...]
> >
> > How do you print them? It seems like you're printing 32-bit value instead
> > ... (powers of 2 are simply shifts of 1).
> >
> >
> I am simply using Rprintf():
> 
>     long long int power[lgth];
>     power[lgth - 1] = 1;
>     Rprintf("power: %d", power[lgth - 1]);
>     for (j = 1; j < lgth; j++) {
>         power[lgth - j - 1] = 2*power[lgth - j];
>         Rprintf(", %d", power[lgth - j - 1]);
>     }
> 
> 
> Basically, I need them in reversed order (hence the inverse indexing), but
> the values are nonetheless the same.
> Adrian
> 
> PS: also tried long long int, same result...

Your numbers are being coerced to int when you print them. Try the
format ", %lld" instead.

Martyn




More information about the R-devel mailing list