Friday, September 30, 2016

Muhammad Akbar

C++ Modifier Types

In the article C++ Data Types along with basic data types like intchardouble you can seeshort intunsigned charlong doublesigned intetc. The words shortunsignedlong,signed are called type modifiers. C++ allows us to use some modifiers for intchar anddouble types
There are four kinds of modifiers:
  1. Signed
  2. Unsigned
  3. Short
  4. Long
As the meaning tells, signed and unsigned modifiers deals with the (+/-) sign of the variable.signed variable stores the signed value in the allocated memory. unsigned variable does not store signed value. Sign takes 1 bit extra. So if we are using unsigned value then we can get one bit extra space to save the value of a variable. The range of values for unsigned types starts from 0.
For example, for int data type range of values is from -2,147,483,648 to 2,147,483,647, and forunsigned int the range is from 0 to 4,294,967,295.
The short modifier makes a type to use less number of bytes and it reduces the range of values for that type. For example, range for short int is from -32,768 to 32,767 in comparison with int that has range from -2,147,483,648 to 2,147,483,647.

Important points to know about modifiers

  1. All four modifiers can be applied to the int type
  2. char type allows only signed and unsigned modifiers
  3. double type can be used with the long modifier
  4. int type allows use of the shorthand notation. So, the following variable definitions are identical
  5. short int a; and short a;
    unsigned int a; and unsigned a;
    long int a; and long a;
  6. The modifiers can be combined. For example, you can use signed or unsigned with longor short modifiers. The correct use of modifiers can reduce the memory usage. So if we know that our variable can never be negative then to save memory we should useunsigned modifiers. And we should short modifier if we know the range of variable will be below 32,767. Below are the examples where you can see even we can use long long

unsigned short a;
unsigned long b;
long long c;
unsigned long long d;

          

      C++ Storage Classes

Muhammad Akbar

About Muhammad Akbar -

Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.

Subscribe to this Blog via Email :

Hello Every One thanks For Visit My site You Can Suggest any Idea About site And Related Education Information Provide me Its Best Content For you am Include in this Site And feel free contact And email now I hope This site very help full you