I was experimenting with bit-fields and unions and created this:

```cpp
union REG{
    struct{
        char posX: 7;
        char posY: 7;
        unsigned char dir:  2;
    };

    unsigned short reg;
};

```

And when I run `sizeof( short )`, I get 2, but when I run `sizeof( REG )`, I get 4. That's weird to me because when I sum the bits I get 7+7+2=16, which is the size in bits of a 2 byte datatype.

I'm currently using the Dev-C++ editor with compiler `TDM-GCC 9.9.2 64-bit Debug`.

This is my first question, so please tell me if you need more information... **Thanks in advance!**

**Edit:** Upon further experimentation I realized the size is the same (2 bytes) when I set the size of posX and posY to 6 bits. But that still puzzles because the sum is 14 bits which is less than 2 bytes...

**Edit 2:** Thanks to AviBerger I realized that replacing the char/unsigned char datatype with short/unsigned short the result of '''sizeof( REG )''' turns into 2. But I still can't figure out **"Why does this happen?"**