C++ signed


Example

A keyword that is part of certain integer type names.

  • When used alone, int is implied, so that signed, signed int, and int are the same type.
  • When combined with char, yields the type signed char, which is a different type from char, even if char is also signed. signed char has a range that includes at least -127 to +127, inclusive.
  • When combined with short, long, or long long, it is redundant, since those types are already signed.
  • signed cannot be combined with bool, wchar_t, char16_t, or char32_t.

Example:

signed char celsius_temperature;
std::cin >> celsius_temperature;
if (celsius_temperature < -35) {
    std::cout << "cold day, eh?\n";
}