Fundamental Data Types in C++
C++ fundamental types represent integral values, floating-point values, the absence of a value, and null pointers.
Summary
C++ fundamental types represent integral values, floating-point values, the absence of a value, and null pointers. A type determines representation, range, and permitted operations. Neither std::string nor arrays are fundamental types.
| Category | Types | Key property |
|---|---|---|
| Integral | bool, character types, signed and unsigned integers | bool has only true and false values |
| Floating-point | float, double, long double | Precision is nondecreasing in this order |
| Special-purpose | void, std::nullptr_t | Represent absence of a value and the type of nullptr, respectively |
Choose types according to required values and operations. sizeof(char) is always one byte, but bits per byte and most other type sizes depend on the implementation. Plain char, signed char, and unsigned char are distinct types; plain char's signedness is implementation-defined. An unsigned integer type with value bits represents through .
π§ Key Concepts
- Integral types
- Floating-point types
- Void and nullptr
- Implementation-dependent sizes
- Integer division
- Unsigned range
- Integer overflow
- Narrowing conversions
- Floating-point precision
- Numeric limits
π§ Quick Check
See what you remember from the summary.
Which is a fundamental C++ type?
π§ Flashcards Preview
Tap a card to reveal the definition.
Ready to quiz yourself?
Test what you remember with a full practice quiz on this note. Create a free account and start in seconds.
Full Notes
Read the original note content before deciding whether to save or study from it.
Fundamental Data Types in C++
π Overview C++ fundamental types represent integral values, floating-point values, the absence of a value, and null pointers. A type determines a value's representation, range, and permitted operations; std::string and arrays are not fundamental types.
π§ Key Idea Choose a fundamental type according to the values and operations a program requires. Type sizes, numeric precision, and conversion rules determine whether those values are represented correctly.
βοΈ Core Details: - Integral types include bool, character types, and signed or unsigned integer types such as short, int, long, and long long. - bool has exactly two values: true and false. - Floating-point types are float, double, and long double, with nondecreasing precision in that order. - sizeof(char) is always one byte; the number of bits per byte and the sizes of most other fundamental types depend on the implementation. - void denotes the absence of a value; std::nullptr_t is the fundamental type of the null pointer literal nullptr. - Brace initialization rejects narrowing conversions, such as converting a fractional double value to int.
π― Why It Matters: - Portable programs avoid assuming that int is always thirty-two bits or that a byte always contains eight bits. - Unsigned arithmetic wraps around, while signed integer overflow causes undefined behavior; choosing a type changes program correctness. - Floating-point rounding can make exact equality unreliable for computed results. - Explicit initialization prevents accidental use of indeterminate values in automatic local variables.
π§ Quick Recall: - Integer division - Division of two integer operands produces an integer result truncated toward zero. - Character types - Plain char, signed char, and unsigned char are distinct types; plain char's signedness is implementation-defined. - Unsigned range - An unsigned integer type with
More ways to study when you copy this note
Copy this note into your library to unlock focused practice sessions and long-term review.
Answer all questions first, then see feedback at the end β the way real exams work.
Focuses each session on what you got wrong, not what you already know.
Full timed exam with all questions, no pausing, and results at the end. Built for board exam prep.
Part of ποΈ BS Information Systems β 1st Year
Browse this Review Set βMore Computer Science notes
See all βMore in Programming Fundamentals
See all βMore from NoteLib
Browse NoteLib's public notes βCopy this note to your library and get the full Study Pack instantly β summary, key concepts, and practice quiz included.