In C on a 32-bit system, which data type will store (and can therefore print) the largest integer? Is it long long
or unsigned long
? Is there an unsigned long long
? And which is the most precise and politically correct?
Longer integers: long The long data type stores integers like int , but gives a wider range of values at the cost of taking more memory. Long stores at least 32 bits, giving it a range of -2,147,483,648 to 2,147,483,647. Alternatively, use unsigned long for a range of 0 to 4,294,967,295.
Memo is the data type that has the largest storage capacity. It provides storage for variable length and arbitrary format data. There are two variations to Memo datatype: CLOB and BLOB data types. CLOB( Character Large Object) are used for storing text.
The integer data type ( int ) is used to represent whole numbers that can be stored within 32-bits. The big integer data type ( bigint ) is used to represent whole numbers that are outside the range of the integer data type and can be stored within 64 bits.
Your question is a bit unclear, but intmax_t
is the largest signed integer-valued type (and uintmax_t
is the largest unsigned integer type). These are typedefs defined in <stdint.h>
, but if you are printing them, you need <inttypes.h>
instead, and the PRInMAX macros for various values of n.
In ISO C99 long long
is at least 64bit which is the largest standard integer data type. It also comes as unsigned long long
. Apparently your compiler might provide larger types wich defined by intmax_t
and uintmax_t
.
However based on your comments you might be looking for a bigint library like GMP. It allows for arbitrary long integers (and floating point) limited in length only by your system resources.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With