The range of int is -2147483648~2147483647.
The calculation method is as follows:
The range of 32-bit int type variables in the computer, where the int type is a signed integer.
Positive numbers are expressed as original codes in the computer, and the highest bit is the sign bit: The original code of
1 is the original code of 0000 0000 0000 0000 0000 0000 0000 0001
2147483647 The code is 0111 1111 1111 1111 1111 1111 1111 1111
So the largest positive integer is 2147483647
Negative numbers are represented as complement codes in the computer, and the highest bit is the sign bit:
-1:
The original code is 1000 0000 0000 0000 0000 0000 0000 0001, the inverse code of
is 1111 1111 1111 1111 1111 1111 1111 1110, the complement code of
is 1111 1111 1111 1111 1111 1111 1111 1111
-2147483647: The original code of
is 1111 1111 1111 1111 1111 1111 1111 1111, the reverse code of
is 1000 0000 0000 000 0 0000 0000 0000 0000 ,
The complement is 1000 0000 0000 0000 0000 0000 0000 0001
So the smallest negative number is -2147483647? Wrong, no.
In binary, there are two table methods for 0.
The original code of 0 is 0000 0000 0000 0000 0000 0000 0000 0000, the original code of
-0 is 1000 0000 0000 0000 0000 0000 0000 0000,
because 0 is only One is needed, so use -0 as the smallest number -2147483648. The complement code of
-2147483648 is expressed as 1000 0000 0000 0000 0000 0000 0000 0000. There is no original code in 32 bits.
Note that this complement is not the real complement. The real complement is 1 1000 0000 0000 0000 0000 0000 0000 0000, which is an overflow.
So the signed 32-bit int type integer is -2147483648~2147483647
Programming can directly call the function to find the range:
#include <limits.h> #include<stdio.h> int max = INT_MAX;//最大数 int min = INT_MIN;//最小数 int main(){ printf("max = %d\nmin = %d\n", max, min); return 0; }
The above is the detailed content of range of int type integers. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)