Get the App
SLTechnology News&Howtos  ›  Database  › 

Explain the maximum value of int in MySQL in depth.

Shulou Source: shulou.com Published: 2022-06-01 04:34:08 09月12日 Update

Introduction

Write about the problems you saw the other day.

Byte

We all know that computers are based on binary. The basic unit of storage is Bit, also known as bits, binary bits. 1bit can represent 0 or 1, which is the smallest amount of information that may exist, and anything less than 1bit is not information.

Complex content is represented by multiple bit. Byte, also known as bytes, is usually used as a unit of measurement. 1 byte equals 8 bit, that is, 1 byte can represent 28 content.

Bytes in MySQL

First of all, the integer types in MySQL can be divided into unsigned and signed, that is, unsigned and signed, the specific content is not expanded here. The size of tinyint is 1 byte, as shown in the following table of numbers that can be represented by the signed type. (note: the table is modified according to the "code". It is only illustrated by examples and does not represent the actual storage of MySQL)

Binary decimal number 10000000-12810000001-12710000010-12610000011-125.11111101-311111110-211111111-100000000000011000000102.011111100124011111101011111111126011111111127

Int maximum

As we can see in the above table, the first bit is used to represent symbols, so there is one less bit to store content in sigend. Int is 4 byte. Combined with the above, we can find that the maximum value of int in signed is

231 − 1147483647

In unsigned, there is no need for the first bit to represent a symbol, so it is

232 − 1: 4294967295

References: binary, bit, byte, complement.

Summary

The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.

Tags: Content binary byte symbol storage maximum maximum information unit that is number type reference learning complexity minimum not above table two represent Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno MySQL Microsoft Xiaomi Docker