C Integer Data Types: Understanding "long", "long long", "long int", and "long long int"
In C , the "long" and "long long" keywords are related to specifying the size and range of integer data types. However, their usage can be confusing, especially if you are transitioning from Java, where "long" is a single data type that holds integers greater than 232.
In C , the data types "long" and "long int" are synonymous and represent a 32-bit signed integer. Similarly, "long long" and "long long int" are synonymous and represent a 64-bit signed integer. The "int" part of the data type specifier is optional.
The C standard mandates minimum ranges for these data types:
This implies that "long long int" always has a wider range than "long int".
In addition to these integer data types, C also offers "long double", which represents a floating-point value. According to the C standard, "long double" must have at least the same precision as "double" and provides a superset of its values, meaning it can hold at least the same range of values as "double" and potentially even more.
Therefore, the primary difference between "long", "long long", "long int", and "long long int" is their size and range. "Long" and "long long" are specifiers that define the size of the integer, while "int" is an optional part of the type specifier. "Long double" is a floating-point data type that is typically used for higher-precision numeric computations.
The above is the detailed content of What\'s the Difference Between \'long\', \'long long\', \'long int\', and \'long long int\' in C ?. For more information, please follow other related articles on the PHP Chinese website!