Integer types

To further explain how the default C and C++ types are defined by their environment, and not by their size, let's look at the integer types. There are three main integer types—short int, int, and long int (excluding long long int, which on Windows is actually a long int).

A short int is typically smaller than an int, and on most platforms, represents 2 bytes. For example, go through the following code:

#include <iostream>int main(void){    auto num_bytes_signed = sizeof(signed short int);    auto min_signed = std::numeric_limits<signed short int>().min();    auto max_signed = std::numeric_limits<signed short int>().max();    auto num_bytes_unsigned = sizeof(unsigned short int); auto min_unsigned = std::numeric_limits<unsigned short int>().min(); ...

Get Hands-On System Programming with C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.