wii nunchuck code

I tried with success the code decodifing the wii Nunchuck accelerometer signals. I'm a beginner with Arduino, although I have experience in using C++, I don't understand the part of the code in the "if.." statements:

if ((nunchuck_buf[5] >> 0) & 1)
z_button = 1;

what does the operator ">>" mean in addition with "&1"? can anyone show me a simple example to understand the code?

complete code i used:

/*
_________
| 1 2 3 |
|       |
| 6 5 4 |
|_-----_|

•pin 1: verde - data (Arduino analog pin 4) 
•pin 2: (not connected) 
•pin 3: rosso - 3.3V 
•pin 4: giallo - clock (Arduino analog pin 5) 
•pin 5: (not connected) 
•pin 6: bianco - GND 
*/

#include <Wire.h> 


void setup()
{
Serial.begin(19200);
nunchuck_init(); // inizializza il nunchuck
}

void loop()
{
nunchuck_get_data();
nunchuck_print_data();
delay(100);
}


//
// Nunchuck functions
//

static uint8_t nunchuck_buf[6];   //array utilizzato per immagazzinare i dati in arrivo dal nunchuck,


void nunchuck_init()
{ 
Wire.begin();                    
Wire.beginTransmission(0x52);    // trasmettiamo l'indirizzo della periferica 0x52
Wire.send(0x40);        // trasmettiamo l'indirizzo della memoria
Wire.send(0x00);        // trasmettiamo uno 0 perchè vogliamo leggere dati
Wire.endTransmission();    // smettiamo di trasmettere
}

void nunchuck_send_request()
{
Wire.beginTransmission(0x52);    //trasmettiamo l'indirizzo del nunchuck 
Wire.send(0x00);        // trasmettiamo un byte
Wire.endTransmission();    // smettiamo di trasmettere
}

// Ricevere dati e immagazzinarli in un buffer
int nunchuck_get_data()
{
int cnt=0;
Wire.requestFrom (0x52, 6);   
while (Wire.available ()) {
// decodifichiamo i byte che ci arrivano e li traformiamo in un intero
nunchuck_buf[cnt] = nunchuk_decode_byte(Wire.receive());
cnt++;
}
nunchuck_send_request();  

if (cnt >= 5) {
return 1;  //restituisce 1 se fallisce
}
return 0; //restituisce 0 se i dati sono stati ricevuti in maniera corretta
}

// Stampare i dati arrivati
// i dati di accelerazione sono lunghi 10 bit
// quindi ne leggiamo 8 poi aggiungiamo
// gli ultimi 2 bit.
void nunchuck_print_data()
{ 
static int i=0;
int joy_x_axis = nunchuck_buf[0];
int joy_y_axis = nunchuck_buf[1];
int accel_x_axis = nunchuck_buf[2]; // * 2 * 2; 
int accel_y_axis = nunchuck_buf[3]; // * 2 * 2;
int accel_z_axis = nunchuck_buf[4]; // * 2 * 2;

int z_button = 0;
int c_button = 0;

// byte nunchuck_buf[5] contains bits for z and c buttons
// it also contains the least significant bits for the accelerometer data
// so we have to check each bit of byte outbuf[5]
if ((nunchuck_buf[5] >> 0) & 1) 
z_button = 1;
if ((nunchuck_buf[5] >> 1) & 1)
c_button = 1;

if ((nunchuck_buf[5] >> 2) & 1) 
accel_x_axis += 2;
if ((nunchuck_buf[5] >> 3) & 1)
accel_x_axis += 1;

if ((nunchuck_buf[5] >> 4) & 1)
accel_y_axis += 2;
if ((nunchuck_buf[5] >> 5) & 1)
accel_y_axis += 1;

if ((nunchuck_buf[5] >> 6) & 1)
accel_z_axis += 2;
if ((nunchuck_buf[5] >> 7) & 1)
accel_z_axis += 1;

Serial.print(i,DEC);
Serial.print(",");
Serial.print("x ");
Serial.print(accel_x_axis, DEC);
Serial.print(",");
Serial.print("y ");
Serial.print(accel_y_axis, DEC);
Serial.print(",");
Serial.print("z ");
Serial.print(accel_z_axis, DEC);
Serial.print(",");
Serial.print("jx ");
Serial.print(joy_x_axis,DEC);
Serial.print(",");
Serial.print("jy ");
Serial.print(joy_y_axis, DEC);
Serial.print(",");
Serial.print(z_button, DEC);
Serial.print(",");
Serial.print(c_button, DEC);

Serial.print("\r\n");  // newline
i++;
}

// metodi di codifica dei nunchuck originali
char nunchuk_decode_byte (char x)
{
x = (x ^ 0x17) + 0x17;
return x;
}

The >> operator is a bit shift operator. The & 1 is a bitwise and. Between the two of them, they test if the nth bit (0, 1, 2, etc.) is 0 or 1. If the bit is 1, the comparison is true. If the bit is 0, the comparison is false.

can you post a simple example to understand the code?

it would be very helpful

if ((nunchuck_buf[5] >> 0) & 1)

can be translated into

if (bit_is_clear(nunchuck_buf[5], 0))