Data Type Modifiers-
These modifiers applicable to all of the basic data types except void data type. They changes the meaning of the base type.
Signed Type Modifier – implies that the data type variable can store positive as well as negative values. For example, if there is a need to declare a variable to store temperature, it can be negative as well as positive.
signed int temperature; or int temperature;Unsigned Type Modifier : implies that the data variable can store only positive values. For example, salary of an employee.
unsigned int empsalary;Long Type Modifier : is used when we need to increase the storage capacity of a variable. For example, annual package of an employee.
long int emppackage;Short Type Modifier : is used when we do not have high range values in a program and containing both positive and negative values also. For example, Roll number of a student.
short int stu_rollnumber;
Why we use these Modifiers or Need of Modifiers –
Need – Computer memory is organized in terms of units called bytes. One byte consists of 8 bits and a bit is the smallest unit of memory. To save the memory of computer system, we can use these modifiers.
Example – Let we need to input “salary of employees”. The data type needed to store salary will be int as salary cannot be in fractions. We also know that the salary cannot be negative. Now an integer is an whole number containing signed and unsigned numbers. As salary cannot be negative, then we can easily remove signed part and can easily save 1 byte by using data type modifiers.
√ Integer Data Type Modifiers :
C++ offers three types of integers – short(2 bytes), int (2 bytes), long (2 bytes) . Each three comes in category of signed and unsigned versions also.
| Type | Approximate Size | Minimal Range | |
| short | 2 | -32768 to 32767 | -215 to 215-1 |
| signed short | 2 | -32768 to 32767 | -215 to 215-1 |
| unsigned short | 2 | 0 to 65535 | 0 to 216-1 |
| int | 2 | -32768 to 32767 | -215 to 215-1 |
| signed int | 2 | -32768 to 32767 | -215 to 215-1 |
| unsigned int | 2 | 0 to 65535 | 0 to 216-1 |
| long | 4 | -2147483648 to 2147483647 | -231 to 231-1 |
| signed long | 4 | -2147483648 to 2147483647 | -231 to 231-1 |
| unsigned long | 4 | 0 to 4294967295 | 0 to 232-1 |
√ Character Data Type Modifiers :
char also have signed and unsigned versions .| Type | Approximate Size | Minimal Range | |
| char | 1 | -128 to 127 | -27 to 27-1 |
| signed char | 1 | -128 to 127 | -27 to 27-1 |
| unsigned char | 1 | 0 to 255 | 0 to 28 |
√ Floating Point Data Type Modifiers :
C++ offers 3 types of floating point – float, double and long double.| Type | Approximate Size | Minimal Range | Digits of Precision |
| Float | 4 | -3.4*10-38 to 3.4*1038-1 | 7 |
| Double | 8 | 1.7*10-308 to 1.7*10-308-1 | 15 |
| Long double | 10 | -3.4*10-4932 to 3.4*104932-1 | 19 |