Reputation: 59
Is it possible to specify a datatype such as int or long to be able to store larger number of bits than it usually supports?
Example int supports 32 bits and long supports 64 bits. What if I want a long to support 128 bits or greater? Is it possible without the help of any libraries?
Upvotes: 1
Views: 126
Reputation: 19761
C is designed to give you a slight abstraction beyond the bare bones of the hardware you are operating on. Because of this, the types that are commonly available correspond to data types the CPU can operate on natively.
Large integer types require multiple CPU instructions to perform basic operations on, and are therefor not native operations and not a part of the core C language.
That's not a rigid definition of C, but it's a reasonable general description of the general gist of the design decisions.
Upvotes: 0
Reputation: 212969
gcc supports built-in __int128_t
and __uint128_t
types on 64-bit platforms.
Upvotes: 0
Reputation: 7610
It is not possible in C. You have to use some libraries like Bigint to achieve it.
Upvotes: 2