Problem sending a 16 bit value through Serial.

Hi, i’m trying to acquire, through a pair of MCP23008 I/O expander, the state of 16 buttons.
I decided to store those values in a 16 bit variable, with every bit representing the state of each button.
Now, i was debugging my sketch and found out that, even if i used a 16 bit variable, when i send its value through serial, the serial monitor shows 32 bits (BIN formatted), and when i update the state of the button corresponding to the MSB, the upper 16 bits (the ones that, in theory, shouldn’t show up) are set all to ‘0’ and disappear.
I tried using int, word and short (16 bit variable types, as stated in the reference), but it always shows a 32 bit value. Is that a bug or there is something that i’m not aware of?
Thanks for your time!

It would help to see your sketch and how you're currently doing things.

daniele_decarolis: when i update the state of the button corresponding to the MSB, the upper 16 bits (the ones that, in theory, shouldn't show up) are set all to '0' and disappear.

1.) MSB = Most Significant BYTE, byte meaning 8 bits - not 16 2.) If they have disappeared, how do you know they were set to '0' before being cast into oblivion?

daniele_decarolis: I tried using int, word and short (16 bit variable types, as stated in the reference), but it always shows a 32 bit value. Is that a bug or there is something that i'm not aware of?

The bug is in the code you didn't post.

Here is how you send a 16 bit number via serial:

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  uint16_t data = 1000;
  byte MSB = (data >> 8) & 0xFF;
  byte LSB = data & 0xFF;

  Serial.print("MSB: "); Serial.println(MSB, BIN);
  Serial.print("LSB: "); Serial.println(LSB, BIN);
  Serial.println();
}

Thanks for the answers. I'm really sorry i didn't post my sketch, it was my first post in this forum. Power_broker thanks for your answer, i thought println would recognize a 16bit value and send it formatted as i would format it. For the "MSB, LSB" confusion, in my school we used those acronyms for "Most (Least) significant bits". I assumed that the 16 bits disappearing into oblivion was due to those being set to 0 and being ignored by the Serial monitor (i confirmed this by sending 255 and 127 through serial). Thanks a lot for the answers you gave me. The next post i submit will be better. Have a good day!

daniele_decarolis: For the "MSB, LSB" confusion, in my school we used those acronyms for "Most (Least) significant bits".

that would be MSb & LSb or msb & lsb, actually i think the latter significant 'bit' (tbh i don't think the 'ms' & 'ls' should be in capitals ever..)