Answer the question
In order to leave comments, you need to log in
Is there an int data type?
Brian Kernighan and Dennis Ritchie's book The C Programming Language says: "The short and long modifiers apply to integers: short int sb; long int counter; The word int in such declarations can be omitted, which is usually done. distinguish between the lengths of the two types of integers for practical purposes.Usually int has a standard length for a particular system.So short is often 16 bits, long is 32 bits, and int is either 16 or 32. The compiler is allowed to choose the size according to with hardware specifications and the following restrictions: numbers of type short and int must be at least 16 bits long, and long must be at least 32 bits long; short must be no longer than int, and int no longer than long.
The question is - int is implemented as a data type that has two modifiers or there are two data types (short and long) and when assigning an int type variable, the compiler decides whether it will be a short or long variable, and int, in this case, is in some kind of abstraction?
Answer the question
In order to leave comments, you need to log in
There are three data types - short int, int and long int.
The compiler does not decide what type the variable will be. The programmer must declare this explicitly.
The compiler decides what size the variable of each type will be.
Just to save screen space and button labor, someone came up with a rule that makes these things equivalent:
shot int a === short a
long int a === long a
When writing programs that care about how much space a variable takes , or how many bits it provides for calculations, it's better not to play the "guess the type size from the compiler and modifier" game, but simply use types with fixed characteristics:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question