为什么mysql的int占四个字节?
PHPz
PHPz 2017-04-17 13:26:52
0
1
690

他的表示范围很大,400000多,那这样算的话一个数字就一个字节,为怎么都会说他只占4个字节呢。

PHPz
PHPz

学习是最好的投资!

reply all(1)
左手右手慢动作

1 bit can only represent 0 or 1 (binary)
8 bits (byte) = 1 byte
can represent data of 2 to the power of 4*8) = 4294967296
Because it needs There are still 0 for positive and negative, so the final representation range (decimal) is -2147483648~2147483647

The data type of the field is fixed. For example, if you declare int(11), note: 11 here represents the length of the number
, then no matter what the length of the stored number is (as long as it does not exceed the representation range of int(11)) mysql will
prepare it in advance Leave so much space as int(11) to store data. The storage size will not be changed based on the size of the data

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!