Binary numbers greater than 127 are not displayed correctly when using the BIT data type.

TXH's profile image TXH posted 1 year ago in General Permalink

Hi, I've been learning mysql recently and now I'm having problems storing BIT data.

When using the BIT data type, the data stored by MySQL conflicts with the results queried by HeidiSQL:

  • x <= 127(0b 0111 1111), correctly displayed.
  • 128(0b 1000 0000) <= x <= 255(0b 1111 1111), Query Display 253(0b 1111 1101).
  • x >= 256(0b 1 1111 1111), Intercept the lower 8 bits of the binary number and repeat the above step.

屏幕截图 2025-05-04 192805.png

This results in the wrong data being used when operating with HeidiSQL.

屏幕截图 2025-05-04 202050.png

Here's the info on the software:

  • HeidiSQL Protable 12.10.0.700(64 Bit)
  • Windows 11 Build 26100
  • MySQL Community Server 8.4.5
  • Character: utf8mb4, Collation: utf8mb4_0900_ai_ci

Please login to leave a reply, or register at first.