[To] the number of bytes corresponding to the Data Type

Source: Internet
Author: User

I. program running platformThe number of bytes allocated for different data types varies on different platforms. My personal understanding of the platform is CPU + OS + compiler, because: 1. 64-bit machines can also be installed with 32-bit systems (Windows XP x64 ); 2. A 32-bit machine can have a 16/32-bit Compiler (on XP, TC is 16-bit, and other common ones are 32-bit ); 3. Even a 32-bit compiler can generate 64-bit integers (int64 ). These are based on the common Wintel platform, and other platforms (other CPU and OS) that we may rarely have access to. Therefore, I personally think that the concept of the platform is a combination of the three. Although the length of the three can be different, it is clear that they work together (that is, the length is equal, 32-bit CPU + 32-bit OS + 32-bit compiler) to maximize the energy. Theoretically, I think the number of bytes of the data type should be determined by the CPU, but it is mainly determined by the compiler (the number of bytes is determined by the compiler during compilation ).
2. number of bytes corresponding to Common Data TypesIt can be obtained by sizeof (char) or sizeof (char *).

32-bit Compiler:

CHAR: 1 byte

Char * (pointer variable): 4 bytes (32-bit addressing space is 2 ^ 32, that is, 32 bits, that is, 4 bytes. Similarly, 64-bit compiler)

Short INT: 2 bytes

INT: 4 bytes

Unsigned INT: 4 bytes

Float: 4 bytes

Double: 8 bytes

Long: 4 bytes

Long long: 8 bytes

Unsigned long: 4 bytes

64-bit Compiler:

CHAR: 1 byte

Char * (pointer variable): 8 bytes

Short INT: 2 bytes

INT: 4 bytes

Unsigned INT: 4 bytes

Float: 4 bytes

Double: 8 bytes

Long: 8 bytes

Long long: 8 bytes

Unsigned long: 8 bytes

[To] the number of bytes corresponding to the Data Type

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.