Home > Common Problem > body text

How many bytes does long occupy?

藏色散人
Release: 2023-02-01 11:50:04
Original
22457 people have browsed it

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)".

How many bytes does long occupy?

#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));
 
}
Copy after login

The output result on a 32-bit machine is:

short=2
int=4
long=4
float=4
double=8
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template