long occupies 4 bytes; long represents a kind of long integer data, which is a basic data type in programming languages. It is the abbreviation of "long int". The default is signed long integer, including 4 bytes, the value range is "-2^31 ~ (2^31 -1)".
#The operating environment of this tutorial: Windows 10 system, version C11, Dell G3 computer.
How many bytes does long occupy?
4.
The long keyword represents a kind of long integer data, which is a basic data type in programming languages. It is the abbreviation of long int. The default is signed long integer type, containing 4 bytes, and the value is The range is: -2^31 ~ (2^31 -1).
The long integer data type is a data type commonly used in programming languages such as C language.
The long integer data type is divided into signed long integer and unsigned long integer. The respective value ranges are as follows:
(1) Long integer type
Type identifier: long[int]
Bytes: 4
Value range on 32-bit machine: -2147483648~2147483647 (-2^31~(2^31- 1))
Portably, write -LONG_MAX-1 ~LONG_MAX
(2) Unsigned long
type Identifier: unsigned long[int]
Bytes: 4
Value range on 32-bit machine: 0~4294967295 (0~(2^ 32-1))
Portably, write 0 ~ ULONG_MAX
Application example
#include <stdio.h> int main() { printf("short=%d\n\n",sizeof(short)); printf("int=%d\n\n",sizeof(int)); printf("long=%d\n\n",sizeof(long)); printf("float=%d\n\n",sizeof(float)); printf("double=%d\n",sizeof(double)); }
The output result on a 32-bit machine is:
short=2 int=4 long=4 float=4 double=8
Recommended learning: "C Video Tutorial"
The above is the detailed content of How many bytes does long occupy?. For more information, please follow other related articles on the PHP Chinese website!