GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing www.geeksforgeeks.org — C++ Type Modifiers - GeeksforGeeks C++ Type ModifiersLast Updated : 13 Jun, 2026 Type modifiers are keywords that alter the properties of fundamental data types in C++. They are used to modify the size, range, or sign of a data type without creating a completely new type.
Type Modifiers in C++C++ provides the following type modifiers:
1. signed ModifierThe signed modifier indicates that a variable can store both positive and negative values. Syntax
The signed modifier is primarily used with integer and character types.
Output Size of signed int: 4 bytes Size of int: 4 bytes Explanation: For integer types, int is signed by default. Therefore, the following declarations are equivalent
2. unsigned ModifierThe unsigned modifier indicates that a variable can store only non-negative values. Since no bits are reserved for storing a sign, the positive range becomes larger than the corresponding signed type. Syntax
Output 4294967286 Explanation: Unsigned types cannot represent negative values. When a negative value is assigned to an unsigned integer, it is converted according to the rules of unsigned arithmetic, producing a large positive value.
3. short ModifierThe short modifier is used with integer types to provide a smaller range than a regular int. Syntax
Output Size of short int: 2 bytes Size of int: 4 bytes Explanation: On many modern systems, short int occupies 2 bytes while int occupies 4 bytes. However, the exact size is implementation-dependent. The C++ standard guarantees:
4. long ModifierThe long modifier is used to increase the range of a data type. Syntax
The long modifier can be used with int and double It can also be repeated with integers:
Output Size of int: 4 bytes Size of long int: 8 bytes Size of double: 8 bytes Size of long double: 16 bytes Explanation: On many 64-bit systems:
However, the exact size may vary depending on the compiler and platform. Size and Range of Modified Data TypesThe exact size and range of modified types depend on the compiler and platform. The following table shows common values on modern 64-bit GCC systems.
When to Use Type ModifiersType modifiers are useful when:
Comment ExploreStandard Template Library(STL) Practice & Problems | |||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |