The number of bytes of an int type.

Source: Internet
Author: User

How many bytes does an int count?

The answer to this question is 4.

However, the number of bytes of int is related to the machine environment.

As you can see, the typical data type sizes match the ILP32LL model, which is what most compilers adhere to on 32-bit platforms. The LP64 model is the de facto standard for compilers that generate code for 64-bit platforms.

I recently read the above explanation in a book about code auditing. Here we explain exactly how many bytes the int should take.

From its perspective, the compiler adapts to the platform. Therefore, the true decision on the number of bytes occupied by the int depends on your device platforms.

In fact, both short and char models are consistent.

The most common model we see is the ilp32ll model. In this model, int and long have 4 bytes of pointer long and 8 bytes of long.


PS: This table is very easy to remember. The numbers in the middle indicate whether you are a 64-bit or 32-bit machine. The front I indicates int, L indicates long, ll indicates long, and P indicates pointer.

The type before the number indicates that it is consistent with the number of bits in the middle. For example, ilp32ll indicates that ILP is 32 bits and ll is 64 bits.


The number of bytes of an int 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.