Why can't tinyint store more than 255 in MySQL?

If TINYINT can store three characters, for example, why can't it store up to number 999?

+4
source share
2 answers

Since it only accepts bit 8 and therefore can encode no more than 2^8 = 256 .

The three characters you see in something like '123' are the result of converting binary to decimal. You cannot store arbitrary characters 3 .

+17
source

This is 8 bits and can actually store a maximum value of 255. 8 bits have 256 possible states, including zero.

+4
source

Source: https://habr.com/ru/post/1302269/


All Articles