Fundamental Data Types Flashcards
Smallest unit of memory
binary digit, known as a bit
Smallest amount of memory that can be addressed directly
a byte
sizeof
can be used to return the size of a type in bytes
signed integers - explain.
2 things to watch out for
used for holding positive and negative whole numbers, including 0. The set of values that a specific data type can hold is called its range.
When using integers, keep an eye out for overflow and integer division problems.
Unsigned integers
only hold positive numbers (and 0), and should generally be avoided unless you’re doing bit-level manipulation
Fixed-width integers
are integers with guaranteed sizes, but they may not exist on all architectures.
The fast and least integers are the fastest and smallest integers that are at least some size.
std::int8_t and std::uint8_t should generally be avoided, as they tend to behave like chars instead of integers
size_t
is an unsigned integral type that is used to represent the size or length of objects
Floating point precision
defines how many significant digits it can represent without information loss
rounding error
when too many significant digits are stored in a floating point number that can’t hold that much precision
floating point number gotcha
don’t compare them directly because of rounding errors