problem with long long int

When I am trying to use the long long int variable with the number 123456789012345 dev C++ says there is an error and gives the message "integer constant is too large for 'long' type".

long long int NUMBER = 123456789012345;

The number is largest than what the long type can support but it is small enough so the long long type can support it. Do someone knows what is happening here? Is it possible my version of C++ doesn't recognise the long long type? Or is it something else?

By the way, I have also tried the 64 bits integers types in the inttypes.h library, and I still got the same error message.
Last edited on
It might be that dev c++'s compiler doesn't recognize/support it yet. Try a different IDE with a different compiler, I recommend code::blocks, but any other might do the trick.
You can see what your limits are

#include <limits>
#include <iostream>

int main() {
	long long int imin = std::numeric_limits<long long int>::min(); // minimum value
	long long int imax = std::numeric_limits<long long int>::max(); // maximum value

	std::cout << imin << " " << imax << std::endl;

	return 0;
Try this:

unsigned long long x = 123456789012345ULL;
mobotus, I ran the code and the output was -9223372036854775808 and 9223372036854775808. What do those numbers represent? Is the limit of the compiler itself?
Last edited on
EssGeEich, it worked. Thanks!
closed account (Dy7SLyTq)
no those numbers are the limit of the operating system
The issue was probably the postfix missing.
You should add a ULL for unsigneds, and I believe it's a LL for signeds, but I'm not sure, you should give that a try.

The limit could also be the compiler's.
Nothing says a compiler cannot use 128 bits for a longlong, even if the operating system natively uses 64.
closed account (Dy7SLyTq)
huh... i thought it was in the standard to use system defined limits. is that wrong then?
Standard just says longlong >= long >= int >= short.
At least this is what I remember.
If you use C++11 and want to be certain of the size, you can use std::uint64_t .
According to , the standard also says that short has to be at least 16 bits, long has to be at least 32, and long long has to be at least 64.

So technically, everything could be 64 bits, though I haven't heard of any implementations where this is actually the case.
Topic archived. No new replies allowed.