Skip to content
Prev 39587 / 63424 Next

Reading 64-bit integers

Dear Simon,

Thank you for the response.
On 29 March 2011 15:06, Simon Urbanek <simon.urbanek at r-project.org> wrote:
The fact remains that I ask for the value of an 8-byte integer and
don't get it. Pretending that it's really only four bytes because of
the limits of R's integer type isn't all that helpful. Perhaps a
warning should be put out if the cast will affect the value of the
result? It looks like the relevant lines in src/main/connections.c are
3689-3697 in the current alpha:

#if SIZEOF_LONG == 8
		    case sizeof(long):
			INTEGER(ans)[i] = (int)*((long *)buf);
			break;
#elif SIZEOF_LONG_LONG == 8
		    case sizeof(_lli_t):
			INTEGER(ans)[i] = (int)*((_lli_t *)buf);
			break;
#endif
Thanks for the code, but I'm not sure I would call that trivial,
especially if one needs to cater for little endian and signed cases as
well! This is what I meant by reconstructing the number manually...

All the best,
Jon