Question: I'm trying to get two bytes in from an SPI sensor and concatenate them (not add them or bitwise OR them). What I have: 11111 and 1111100. What I want: 0001111101111100 (8060 in decimal). 

When I Serial.print(firstByte, BIN) my two bytes, Arduino seems to remove the leading 0's (probably because there is some kind of conversion going on and those 0' are do not contribute to the value of the number or something). 

That's a problem for me because I would like to concatenate those two bytes including the leading 0's before converting that two-byte binary number into a decimal integer. 

Does anyone know a good approach? I'm thinking storing them as a char array, but not sure exactly. In the above example, I could just manually add in a '0' but then it would really only work if those bit values never changed, and that would be a problem.

Here is my code for reference:
<https://gist.github.com/vwls/852fb5c53112efc77faaecd6bffba25f>

Any advice would be really helpful!

Answer: 
```
#include <iostream>   // only for debug output

int main()
{
    // example how to concatenate two 8 bit values into 16 bit value
    uint8_t b1 = 0b11111, b2 = 0b1111100;
    uint16_t r = (b1<<8) | b2;
    // debug output, the value is already composed in 16b "r" variable
    std::cout << int(b1) << " " << int(b2) << " = " << int(r) << "\n";
}

```

output: `31 124 = 8060`

(sorry, I don't have Arduino SDK to verify this is compilable, hopefully the `uint**` types are selfexplanatory.)

`|` is binary OR concatenating the values, `b1` is shifted by 8 bits left (`<<8`) first, to not overlap with `b2` bits.

further edit: this **is** C++ (C++11 actually). Adjust to Arduino compiler as needed. The `|` and `<<` operators are part of original C since beginning, so you have to fix only variable types, and make sure it works. Bitwise operations are the same both in C and C++.
If you need one 16bit wide variable, you can use for example bit shifting.
Something like:

```
uint16_t result = SPI.transfer(...);
result <<= 8;
result |= SPI.transfer(...);

```