From plummerm at iarc.fr  Wed May 14 17:24:12 2014
From: plummerm at iarc.fr (Martyn Plummer)
Date: Wed, 14 May 2014 15:24:12 +0000
Subject: [Rd] large integer values
In-Reply-To: <CAJ=0CtDJpK+9HBVsMB=LxtbKQR8tW=bzfbeDjZtRosKdi945GQ@mail.gmail.com>
References: <CAJ=0CtBbsqpx54p---oGxziiSLum4_k449z+hjtSjuQDdSk0Mw@mail.gmail.com>
	<5373575E.4030906@stats.ox.ac.uk>
	<CAJ=0CtA2yt28cT-j5mP5M0a3_s_XZ8f3iJ4kQPm6NzmZS7a6iw@mail.gmail.com>
	<A4FBBBFD-7E66-444A-BEF0-7F2B40613D5F@r-project.org>
	<CAJ=0CtDJpK+9HBVsMB=LxtbKQR8tW=bzfbeDjZtRosKdi945GQ@mail.gmail.com>
Message-ID: <1400081052.3610.1.camel@braque.iarc.fr>

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




[Rd] large integer values
Martyn Plummer