What are C qualifiers?

I read the text at this URL:

https://cs.senecac.on.ca/~btp100/pages/content/varia_p.html

In the Qualifiers section, they say:

"We can qualify the int type to be sure that it contains the minimum number of bits" .... Short contains at least 16 bits: ....

I do not understand this, which means "qualify an int type" and why "Short contains at least 16 bits."

Can anyone explain this? Thanks to everyone.

+4
source share
5 answers

You can use Qualifiers to indicate what size number you want to keep inside your int. Think that the exact size depends on the implementation of C, but usually it looks like this.

short int a; // 16 bits, range -32,768 to 32,767

unsigned short int b; // 16 bits, range 0 to 65,535

unsigned int c; // 32 bits, range 0 to 4,294,967,295

int d; // 32 bits, range -2,147,483,648 to 2,147,483,647

long int d; // 32 bits, range -2,147,483,648 to 2,147,483,647 (minimum requirement, can be higher on 64bit systems)

0
source

Qualifier - an additional name assigned to any variables or functions, showing additional quality or additional meaning for this variable or function. like Dr. Dr. Arun Kumar

Qualifiers for variables (TYPE qualifiers): signed , unsigned , long , short , long long , const , volatile , static , auto , extern , register

Qualifiers for functions: static , extern , inline

+11
source

keywords short , long , unsigned , signed , etc. called qualifiers. The order of qualifiers does not matter, for example

 short int signed x; // means signed short int x, at least 16 bits :) 

In this line, you defined an int type with short and signed qualifiers

+5
source

Some keywords change the behavior of type "int". They are known as a qualifier. Examples include short, long, unsigned, const, volatile. Therefore, if we qualify "int" with "short", we know that the variable contains at least 16 bits:

 short int var; 
+1
source

Logically, an integer is any integer, from negative infinity to positive infinity.

It would be nice if C / C ++ could declare an int and use it to store any integer, but, unfortunately, there should be restrictions on the range of values ​​that you can store in an int data type.

C / C ++ allows you to declare short, int, or long types of variables that can store 2 ^ 16, 2 ^ 32, and 2 ^ 64 different integers, respectively.

Saying that int is qualified is the same as saying that it is bounded to contain a smaller subset of integers.

0
source

Source: https://habr.com/ru/post/1341120/


All Articles