Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What is the int data range and memory storage of C language?
What is the int data range and memory storage of C language?
Type 1 and nt are signed integer types, and for 16-bit compiler, int occupies 2 bytes and 8 bits; For 32-bit and 64-bit compilers, int type accounts for 4 bytes and 32 bits. The value range of int type varies with the occupied space: when it is 2 bytes, the value range of int is-32768 ~ 32767; At 4 bytes, the range of int is-2147483648 ~ 2147483647.

Either way, the most significant bit is the sign bit, 0 represents a positive number, and 1 represents a negative number. The remaining bits store the actual values.

2. Characters refer to letters, numbers, words and symbols used in computers, including: 1, 2, 3, a, b, c, ~! #¥%? -* ()-+and so on. In ASCII coding, it takes 1 byte to store an English alphabetic character. In GB 23 12 coding or GBK coding, a Chinese character needs to store 2 bytes.

3. Character data is stored in memory with its ASCII code value (one byte). All data types are stored in memory with 0 and 1 code binary. This principle will not change.

4. In UTF-8 coding, an English alphabetic character memory needs 1 byte, and a Chinese character memory needs 3 to 4 bytes. In UTF- 16 coding, an English alphabetic character or a Chinese character needs 2 bytes (some Chinese characters in Unicode extension need 4 bytes). In UTF-32 coding, it takes 4 bytes to store any character in the world.

5.char is one of C/C++ integer data, and others, such as int/long/short, are signed by default without specifying signed/unsigned. Char is unsigned in the standard, and the compiler can be implemented as signed or unsigned. Some compilers, such as the compiler of pSOS, can also specify whether it is signed or unsigned through the compilation switch.