Re: Simply C/C++ problem!

From: Claudi Astres <claudi_at_astres.cat>
Date: Wed, 11 Aug 2010 13:49:27 +0200


Hi Ian,
Please do a simple check:
printf("%d\n", sizeof(ULD));

This statement should dump 8.

On the other hand try to do:
((ULong64_t) 1) << mem[i][k] instead of 1 << mem[i][k], for all k=0..5

Cheers,
Claudi

El 11/08/2010, a las 13:18, Dr Ian Korir escribió:

> Dear ROOTers,
>
> I need to perform some simple bit "manipulations" without making
> use of
> the TBit ROOT object on a 64 bit variable ULD declared as (supposedly)
> unsign long long, then get a printout of the same variable using
> printf.
> My problem is it does not seem to work or seems to truncate the output
> to 32 bits. Here is the relevant portion of the code that does this:
>
> ULong64_t ULD;
> for (Int_t i=0; i<10; i++){
> printf("\n(%3i)", i+1);
> ULD=0;
> ULD|=1<<mem[i][0];
> ULD|=1<<mem[i][1];
> ULD|=1<<mem[i][2];
> ULD|=1<<mem[i][3];
> ULD|=1<<mem[i][4];
> ULD|=1<<mem[i][5];
> ULD>>=1;
> printf(" %llu ", ULD);
> }//for ith
>
> The mem[i][j] is a 2D array of Int_t etc and the process above is
> meant
> to set appropriate bits to 1 initialised with all zeros (supposedly),
> how can one fix this to perform as one might expect?
>
> Uses root version 5.26/00 under OS SL52 environment (HP Z600 64Bit
> Quad)
>
>
> Regards,
>
> Ian.
>
>

El 11/08/2010, a las 13:18, Dr Ian Korir escribió:

> Dear ROOTers,
>
> I need to perform some simple bit "manipulations" without making
> use of
> the TBit ROOT object on a 64 bit variable ULD declared as (supposedly)
> unsign long long, then get a printout of the same variable using
> printf.
> My problem is it does not seem to work or seems to truncate the output
> to 32 bits. Here is the relevant portion of the code that does this:
>
> ULong64_t ULD;
> for (Int_t i=0; i<10; i++){
> printf("\n(%3i)", i+1);
> ULD=0;
> ULD|=1<<mem[i][0];
> ULD|=1<<mem[i][1];
> ULD|=1<<mem[i][2];
> ULD|=1<<mem[i][3];
> ULD|=1<<mem[i][4];
> ULD|=1<<mem[i][5];
> ULD>>=1;
> printf(" %llu ", ULD);
> }//for ith
>
> The mem[i][j] is a 2D array of Int_t etc and the process above is
> meant
> to set appropriate bits to 1 initialised with all zeros (supposedly),
> how can one fix this to perform as one might expect?
>
> Uses root version 5.26/00 under OS SL52 environment (HP Z600 64Bit
> Quad)
>
>
> Regards,
>
> Ian.
>
Received on Wed Aug 11 2010 - 13:49:39 CEST

This archive was generated by hypermail 2.2.0 : Wed Aug 11 2010 - 17:50:01 CEST