What is the difference between an int and a long in C++?

后端 未结 9 769
执笔经年
执笔经年 2020-11-22 07:15

Correct me if I am wrong,

int is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31)
long is 4 bytes, with a range of values from -2,147,

9条回答
  •  萌比男神i
    2020-11-22 07:59

    The C++ specification itself (old version but good enough for this) leaves this open.

    There are four signed integer types: 'signed char', 'short int', 'int', and 'long int'. In this list, each type provides at least as much storage as those preceding it in the list. Plain ints have the natural size suggested by the architecture of the execution environment* ;

    [Footnote: that is, large enough to contain any value in the range of INT_MIN and INT_MAX, as defined in the header . --- end foonote]

提交回复
热议问题