Aman Jaiswal
Aman Jaiswal

Reputation: 1093

different size of c data type in 32 and 64 bit

Why there is different size of C data types in 32bit and 64 bit system...

for example: int size in 32bit is 4 byte and 8 byte in 64bit

what is the reason behind it to double the size of data types in 64bit as well as My knowledge is concern there is no performance issue if we are going to use same size in 64 bit system as it is in 32 bit....

Upvotes: 3

Views: 6063

Answers (2)

John Bode
John Bode

Reputation: 123558

The C language definition does not mandate a specific size for most data types; instead, specifies the range of values each type must be able to represent. char must be large enough to represent a single character of the execution character set (at least the range [-127,127]), short and int must be large enough to represent at least the range [-32767,32767], etc.

Traditionally, the size of int was the same as the "natural" word size for a given architecture, on the premise that a) it would be easier to implement, and b) operations on that type would be the most efficient. Whether that's still true today, I'm not qualified to say (not a hardware guy).

Upvotes: 0

John Bollinger
John Bollinger

Reputation: 181159

Why there is different size of C data types in 32bit and 64 bit system[?]

The sizes of C's basic data types are implementation-dependent. They are not necessarily dependent on machine architecture, and counterexamples abound. For example, 32-bit and 64-bit implementations of GCC use the same size data types for x86 and x86_64.

what is the reason behind it to double the size of data types in 64bit[?]

The reasons for implementation decisions vary with implementors and implementation characteristics. int is often, but not always, chosen to have a size that is natural for the target machine in some sense. That might mean that operations on it are fast, or that it is efficient to load from and store to memory, or other things. These are the kinds of considerations involved.

Upvotes: 3

Related Questions