How many bytes does long occupy?
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!

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics

1MB of storage capacity is equivalent to 2 to the 20th power bytes, or 1,048,576 bytes. MB is a storage unit in computers, pronounced as "mega"; because 1MB is equal to 1024KB, and 1KB is equal to 1024B (bytes), so 1MB is equal to 1048576 (1024 *1024) bytes.

128mb refers to 134217728 bytes; the byte conversion formula is "1MB=1024KB=1048576B=8388608bit", which means that 1048576 English letters and 524288 Chinese characters can be saved; the traffic unit conversion formula is 1GB=1024MB, 1MB=1024KB, 1KB= 1024B.

1 bit is equal to one-eighth of a byte. In the binary number system, each 0 or 1 is a bit (bit), and a bit is the smallest unit of data storage; every 8 bits (bit, abbreviated as b) constitute a byte (Byte), so "1 byte ( Byte) = 8 bits”. In most computer systems, a byte is an 8-bit (bit) long data unit. Most computers use a byte to represent a character, number, or other character.

One ascii character occupies 1 byte. ASCII code characters are represented by 7-bit or 8-bit binary encoding in the computer and are stored in one byte, that is, one ASCII code occupies one byte. ASCII code can be divided into standard ASCII code and extended ASCII code. Standard ASCII code is also called basic ASCII code. It uses 7-bit binary numbers (the remaining 1 binary digit is 0) to represent all uppercase and lowercase letters, and the numbers 0 to 9. Punctuation marks, and special control characters used in American English.

An ASCII code occupies one byte. ASCII code is a coding standard used to represent characters. It uses 7-bit binary numbers to represent 128 different characters, including letters, numbers, punctuation marks, special characters, etc. A byte is the basic unit of computer storage unit. It consists of 8 binary bits. Each binary bit can be 0 or 1. One byte can represent 256 different values, so it can represent all characters in the ASCII code.

UTF8 encoded Chinese characters occupy 3 bytes. In UTF-8 encoding, one Chinese character is equal to three bytes, and one Chinese punctuation mark occupies three bytes; while in Unicode encoding, one Chinese character (including traditional Chinese) is equal to two bytes. UTF-8 uses 1~4 bytes to encode each character. One US-ASCIl character only needs 1 byte to encode. Latin, Greek, Cyrillic, Armenian, and Hebrew with diacritical marks. , Arabic, Syriac and other letters require 2-byte encoding.

How to query long type in oracle: 1. TO_LOB function, use "SELECT TO_LOB()" syntax to convert the LONG type column in the table to CLOB type and return it as the query result; 2. SUBSTR function, use "SELECT SUBSTR() )" will return the 250 characters starting from the 100th character in the LONG type column in the table, which are returned as VARCHAR type.

4KB means that the storage unit is 4096 bytes. KB refers to kilobyte, which is a multiple form of computer data storage unit byte. A kilobyte is based on the power of 2, that is, a kilobyte (1KB) is equal to 1024 bytes (B ); therefore "4KB=4*1024B=4096B", that is, 4KB represents 4096 bytes.