Re: Simply C/C++ problem!

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Wed, 11 Aug 2010 13:46:28 +0200


Hi,

use 1ll << mem[i][...] (that's "one ell ell"). Otherwise you shift the one out of the number of available bits, or as GCC puts it: warning: left shift count >= width of type.

Cheers, Axel.

Dr Ian Korir wrote on 08/11/2010 01:18 PM:
> 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:46:32 CEST

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