Home > Backend Development > C++ > What\'s the Difference Between \'long\', \'long long\', \'long int\', and \'long long int\' in C ?

What\'s the Difference Between \'long\', \'long long\', \'long int\', and \'long long int\' in C ?

Linda Hamilton
Release: 2024-10-29 01:43:02
Original
386 people have browsed it

 What's the Difference Between

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:

  • "long int" has at least the same range as a 32-bit signed integer.
  • "long long int" has at least the same range as a 64-bit signed integer and is at least as wide as "long int".

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template