I know that an integer has a range of -2147483648 to 2147483647 and a long has the range of -9223372036854775808 to 9223372036854775807 but what range does a long int have?
Asked
Active
Viewed 417 times
0
-
6`long` and `long int` are the same thing. The `int` is optional. – Pete Becker Dec 18 '21 at 16:27
-
Does this answer your question? [Long Vs. Int C/C++ - What's The Point?](https://stackoverflow.com/questions/7456902/long-vs-int-c-c-whats-the-point) – Karl Knechtel Dec 18 '21 at 16:27
-
1`int` can be omitted when any of `signed`, `unsigned`, `long` or `short` are used. `long` and `long int` mean the exact same thing. – François Andrieux Dec 18 '21 at 16:29
-
1*"I know that `long` has the range of -9223372036854775808 to 9223372036854775807"*. Only when the `long` is 64-bits. It can be 32 bits. – Weather Vane Dec 18 '21 at 16:41
-
`integer has a range of -2147483648 to 2147483647 and a long has the range of -9223372036854775808 to 9223372036854775807` the C and C++ standards don't specify any specific size for any built-in types. The only requirement is that `int` has at least 16 bits and `long` has at least 32 bits: [What does the C++ standard state the size of int, long type to be?](https://stackoverflow.com/q/589575/995714) – phuclv Dec 18 '21 at 16:53
-
`long`, `long int`, `signed long` and `signed long int` all refer to the same type. But you're wrong about the range of both `int` and `long`. See [C data types](https://en.wikipedia.org/wiki/C_data_types) Used the fixed-width integer types mentioned therein if you want to guarantee certain ranges. – ikegami Dec 18 '21 at 17:03
1 Answers
2
I know that an integer has a range of -2147483648 to 2147483647
Then you know wrong. The standard only says minimum values and those are much lower than those (-32767, 32767).
C language has special defines for the minimum and maximum integer values. For example for the int
type: INT_MIN
& INT_MAX
. They are defined in the limits.h
header file.
You can also check how long (in char
) your type is by using sizeof
operator. If you want to know haw many bits
it has: sizeof(type) * CHAR_BIT
What is the difference between long and long int in c?
There us no difference as int
can be omitted. Same is with unsigned
(unsigned int
), short
(short int
) and long long
(long long int
).

0___________
- 60,014
- 4
- 34
- 74
-
the limit for `int` is `[-32767, 32767]`, not (-32768, 32767) because C and older C++ allows one's complement and sign-magnitude formats – phuclv Dec 18 '21 at 16:55
-