Integer vs Floating Point Types
Pick the right numeric type by understanding sizes, ranges, and precision trade-offs.
Two Number Worlds
C++ has two families of numeric types: integers (no fractions, exact) and floating point (approximate, with fractions). Pick the right family for the job.
Integer Types
Built-in integer types and typical sizes on 64-bit systems:
char— 1 byteshort— 2 bytesint— 4 byteslong— 4 or 8 byteslong long— 8 bytes
All lessons in this course
- Integer vs Floating Point Types
- The cmath Header: pow sqrt abs round
- Random Numbers with the random Header
- Numeric Limits and Overflow Behaviour