Int occupies the word length of a machine.

Source: Internet
Author: User

 

INT and short int are different.

According to the C ++ standard, int occupies the word length of a machine. In 32-bit systems, int occupies 32 bits, that is, 4 bytes,

In the old 16-bit system, int occupies 16 bits, that is, two bytes.

 

The C ++ standard only specifies that the short int cannot exceed the length of the int. The specific length can be determined by the Implementation vendor of the C ++ compiler. Currently, in the popular 32-bit C ++ compiler,

Generally, int occupies 4 bytes, while short int occupies 2 bytes. Short int can be abbreviated as short. Similarly, the C ++ standard only limits the length of long int to be smaller than that of Int.

 

 

It should be related to the CPU architecture and the compilation system. Haha.
I am also confused about this problem !!!

 

The result of my 32-bit machine VC ++ is


Short integer short Int = 16-bit = 2 bytes
Integer Int = 32-bit = 4 bytes
Long Integer long Int = 32-bit = 4 bytes
Single precision float = 32-bit = 4 bytes
Double = 64-bit = 8 bytes
Long Integer double = 64-bit = 8 bytes
Character char = 8-bit = 1 byte
Unsigned escape char = 8-bit = 1 byte
Signed signature type signed Char = 8-bit = 1 byte
Unsigned integer Int = 32-bit = 4 bytes
Signed integer signed Int = 32-bit = 4 bytes
Unsigned long integer signed long Int = 32-bit = 4 bytes

 

In tc2.0

Short Int = 16 bit = 2 byte
Int = 16 bit = 2 byte
Long Int = 32 bit = 4 byte
Float = 32 bit = 4 byte
Double = 64 bit = 8 byte
Long Double = 80 bit = 10 byte
Char = 8 bit = 1 byte
Unsigned char = 8 bit = 1 byte
Signed Char = 8 bit = 1 byte
Unsigned Int = 16 bit = 2 byte
Signed Int = 16 bit = 2 byte
Signed long Int = 32 bit = 4 byte

 

TC
Long Double = 80 bit = 10 byte
VC ++
Long Double = 64-bit = 8 bytes

2 bytes missing

My summary should be related to the compilation system, which is defined by the machine.
Also follow short int <= long int

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.