In-depth explanation of the maximum value of int in MySQL

In-depth explanation of the maximum value of int in MySQL

Introduction

I will write about the problem I saw two days ago in detail.

byte

We all know that computers are based on binary. The basic unit of storage is Bit, also called bit or binary bit. 1 bit can represent two numbers, 0 or 1, and is the smallest possible amount of information. Any content less than 1 bit is not considered information.

Complex content must be represented by multiple bits. Byte, also known as byte, is often used as a unit of measurement. 1 byte is equal to 8 bits, that is, 1 byte can represent 28 contents.

Bytes in MySQL

First of all, let me explain that the integer type in MySQL can be divided into two types: unsigned and signed. The specific content will not be expanded here. The size of tinyint is 1 byte. The numbers that can be represented by signed type are shown in the following table. (Note: The table is modified according to the "Coding" and is only used as an example. It does not represent the actual storage of MySQL)

Binary Numbers Decimal Numbers
10000000 -128
10000001 -127
10000010 -126
10000011 -125
... ...
11111101 -3
11111110 -2
11111111 -1
00000000 0
00000001 1
00000010 2
... ...
011111100 124
011111101 125
011111110 126
011111111 127

int maximum value

As we can see in the table above, the first bit is used to represent the sign, so there is one less bit in sigend to store the content. Int is 4 bytes. Combining the above, we can conclude that the maximum value of int in signed form is

231−1=2147483647

In unsigned, the first bit is not required to indicate the sign, so

232−1=4294967295

References: binary, bit, byte, complement.

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of the meaning of M in MySQL data type int(M)
  • How to convert varchar type to int type in Mysql database
  • Example of changing the auto-increment primary key type from int to char in mysql
  • Explanation of the usage of replace and replace into in MySQL
  • MySQL adds a foreign key error: 1215 Cannot add the foreign key constraint solution
  • How to convert mysql date type and int type
  • Slow query caused by converting int to varchar in MySQL database
  • Full analysis of MySQL INT type

<<:  Axios secondary encapsulation example Demo in the project

>>:  CentOS 7.2 builds nginx web server to deploy uniapp project

Recommend

Vue+element+oss realizes front-end fragment upload and breakpoint resume

Pure front-end implementation:切片上傳斷點續傳.斷點續傳needs ...

How to create WeChat games with CocosCreator

Table of contents 1. Download WeChat developer to...

How to install openjdk in docker and run the jar package

Download image docker pull openjdk Creating a Dat...

Two ways to specify the character set of the html page

1. Two ways to specify the character set of the h...

Sample code for using CSS to write a textured gradient background image

The page length in the project is about 2000px or...

Quickly solve the problem that CentOS cannot access the Internet in VMware

Yesterday I installed CentOS7 under VMware. I wan...

CSS float (float, clear) popular explanation and experience sharing

I came into contact with CSS a long time ago, but...

Parse CSS to extract image theme color function (tips)

background It all started when a classmate in the...

MySQL database SELECT query expression analysis

A large part of data management is searching, and...

Detailed installation tutorial of Docker under CentOS

Docker is divided into CE and EE. The CE version ...

React event binding details

Table of contents Class component event binding F...

CSS3 new layout: flex detailed explanation

Flex Basic Concepts Flex layout (flex is the abbr...

Summary of MySQL log related knowledge

Table of contents SQL execution order bin log Wha...

Detailed explanation of JavaScript upload file limit parameter case

Project scenario: 1. Upload file restrictions Fun...