Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

mysql

tinyint

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

like image 309
Mohamad Avatar asked Feb 24 '10 18:02

Mohamad


2 Answers

Because it takes only 8 bit and hence can encode no more than 2^8 = 256 values.

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

like image 164
Quassnoi Avatar answered Oct 24 '22 01:10

Quassnoi


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

like image 32
TWA Avatar answered Oct 24 '22 01:10

TWA