Which is the biggest integer datatype in c++?
In the Borland and Microsoft compilers, __int64 is probably the largest you can get.
The long long
data-type is the largest built-in integral datatypes in standard C99 and C++0x. Just as with all of the other integral data types, long long
is not given an exact size in bytes. Instead, it is defined to be at least a 64-bit integer. While long long
is not part of the official C++ standard, it is ubiquitously supported across modern compilers. Note, however, that many compilers for modern desktops define long
and long long
as both exactly 64-bits, whereas many compilers for embedded processors define long
as 32-bits and long long
as 64-bits (obviously witha few exceptions).
If you need more precision or absolutely cannot use the long long
language extension, you're going to have to use one of the C or C++ libraries that are designed to work with extremely large or small numbers.
You can easily get bigger datatype by defining your own Class. You can get inspired from the class BigInteger in Java. It's a nice one but it's not necessarily an actual integer even if it acts exactly like one.
There are 128 bit packed integer and floating point formats defined in xmmintrin.h on compilers that support SSE to enable use of the SSE registers and instructions. They are not part of the C++ standard of course, but since they are supported by MSVC, GCC and the Intel C++ Compiler there is a degree of cross-platform support (at least OS X, Linux and Windows for Intel CPUs). Other ISAs have SIMD extensions so there are probably other platform/compiler specific extensions that support 128 or 256 bit SIMD instructions. Intel's upcoming AVX instruction set will have 256 bit registers, so we should see a new set of data types and intrinsics for that.
They don't behave quite like built-in data types (i.e., you have to use intrinsic functions instead of operators to manipulate them, and they work with SIMD operations) but since they do in fact map to 128-bit registers on the hardware they deserve mention.
The biggest standard C++ integer type is long
.
C has a long long
, and C++0x is going to add that as well, and of course you could implement your own custom integer type, perhaps even a BigInt class.
But technically speaking, considering the built-in integer types, long
is your answer.