Arduino compiler don't behave like my other C++ compiler (shift operator)

Hi!

Today I have wasted alot of time debugging one of my project (creating a wirless sensor using the fine offset protocol).

I just noticed that the Arduino compiler don't behave like my other C++ compiler (Quincy 2005) that I often use to write code before I paste it in my Arduino sketch.

The code below should output the following line:
010001011100 000011111011 01000101

When I run the code (just replace Serial.print with cout <<) in Quincy 2005 everything works.
I also think that is should, it is just plan shift operators.

The Arduino is outputting:
010001011100 000100000000 00000000
Which I think is wrong.

What is wrong with the code?

uint32_t data=0;
void setup()
{
  Serial.begin(9600);
  data = ((data << 8) +  reverse(69,8));  //humidity 69%
  data = ((data << 12) +  reverse(251,12)); //Temperature 25,1 degree
  data = ((data << 12) +  reverse(1116,12)); //Sensor ID

//Print sensor ID
  for (int i=0;i<12;i++)
  {

    if ((data) & (1<<(i)))
    {
      Serial.print(1);
    }
    else
    {
      Serial.print(0);
    }
  }
  Serial.print(' ');
//Print temp
  for (int i=12;i<24;i++)
  {

    if ((data) & (1<<(i)))
    {
      Serial.print(1);
    }
    else
    {
      Serial.print(0);
    }
  }
  Serial.print(' ');
//Print humidity 
  for (int i=24;i<32;i++)
  {

    if ((data) & (1<<(i)))
    {
      Serial.print(1);
    }
    else
    {
      Serial.print(0);
    }
  }  	    	
 
}

void loop()
{

}

uint16_t reverse (uint16_t num,uint8_t bits) {
  uint16_t reversed = 0;
  for ( int b=0 ; b < bits ; b++ ) reversed = ( reversed << 1 ) | ( 0x0001 & ( num >> b ) );
  return reversed;
}

16 bit "int" vs. 32 bit "int"?

for (int i=12;i<24;i++)
  {

    if ((data) & (1<<(i)))

Thanks!!!

We both know the answer, but maybe now is the time to share for others in future who have the same or a similar question...

Yes, you'r right.

I changed the if statement to:

for (uint32_t i=12;i<24;i++)
  {
    if ((data >> i) & 1 )

Now my homemade sensor works!