problem with bitwise OR
Correction from another answer for number2:

number2 = (unsigned long)byte3 &lt;&lt;24 | (unsigned long)byte2 &lt;&lt;16 | byte1 &lt;&lt;8 | byte0; // = 4.000.000.001


And in the first round of loop number3 is correct, all others are wrong as number3 holds a result from previous loop.

  number3 = byte3; // all magic lays here
  number3 &lt;&lt;= 8;
  number3 |= byte2;
  number3 &lt;&lt;= 8;
  number3 |= byte1;
  number3 &lt;&lt;= 8;
  number3 |= byte0;