Unsure about how the code works for this Make-It Robotics kit
Indeed, the way the bitwise operations are written is confusing.

  if((sensor_in &amp; 0xf00)==0)
    sensorValue1=sensor_in &amp; 0xff;
  else if((sensor_in &amp; 0xf00)&gt;&gt;8==1)  
    sensorValue2=sensor_in &amp; 0xff;
  if (sensorValue1 == 0x00)
    action1 =action1 &amp; 0xfe;
  if (sensorValue1 == 0xFF)
    action1 = action1 | 0x01;
  if (sensorValue2 == 0x00)
    action1 = action1 | 0x02;
  if (sensorValue2 == 0xFF)
    action1 = action1 &amp; 0xfd;  


Basically you have two input values that can be in the same variable - differentiated by the 9th bit of the value.  Values between 0 and 255 relate to one sensor, between 256 and 511 to the other.  The bitwise operators split that into sensorValue1 and sensorValue2 accordingly.

Then those sensor values are compared to 0 or 255 and used to define the action to perform - that action being comprised of the lowest two bits of a byte variable, so you have three possible actions:

0 = both sensors off
1 = sensor 1 on, sensor 2 off
2 = sensor 1 off, sensor 2 on
3 = both sensors on


The comments in the program also tell you this information:

action1
         left        right
0x00    black        black
0x01    black        white
0x02    white        black
0x03    white        white


Now you have how to deal with the action value:

if(action1 != action2)
{
  if (action1 == 3 )
    line_following.go_forward(50);
  if (action1 == 1)
    line_following.line_following_turn_left(50);    
  if (action1 == 2)
    line_following.line_following_turn_right(50);  
  if (action1 == 0)
    line_following.go_forward(50);  
}
action2=action1;  


So if the action has changed, we can change what we are doing:


If action is 3, so if both sensors read as white, or if action is 0, so both sensors read black (in other words if both sensors read the same) then move forwards.
If action is 1 (so the left sensor reads black) then turn to the left.
If action is 2 (so the right sensor reads black) then turn to the right.


So basically if it doesn't know anything better, it drives forwards, otherwise it turns in the direction that it finds the black line, thus keeping it always on that line.  As it drifts off the line one sensor will sense white, so the robot will turn away from that whiteness and back on to the line.