How do I use a i2c port expander to read buttons with pull ups and inverting the resulting uint16_t? I am using a mcp23017 to read button presses for my joystick project and am using the internal pullup to minimize complications. Is there a way to invert all the bits in the uint16_t so i can send the values as normally off?

I'm using this Adafruit library.

And the reading code: uint16_t buttons = mcp.readGPIOAB();
The inversion operator in C++ is ~.

Serial.print(buttons, BIN);
Serial.print(~buttons, BIN);