Integer data types

Objective

  • Use integer data types with specific qualities

Integer data types

  • Traditional: short, int, long, long long
  • Long names for traditional types: short int, int, long int, long long int
  • Any of the int types may be preceded by "unsigned".
  • More specific types are defined in the cstdint library.
  • The old C library name is stdint.h
  • The items in cstdint are not in a namespace, so no "using" statements are needed.
  • See http://www.cplusplus.com/reference/cstdint/ for cstdint details
  • The types listed below include both a signed and unsigned version
  • Integer type with maximum size: intmax_t, uintmax_t
  • Integer type with at least 8 bits: int_least8_t, uint_least8_t
  • Integer type with at least 16 bits: int_least16_t, uint_least16_t
  • Integer type with at least 32 bits: int_least32_t, uint_least32_t
  • Integer type with at least 64 bits: int_least64_t, uint_least64_t
  • Fastest integer with at least 8 bits: int_fast8_t, uint_fast8_t
  • Fastest integer with at least 16 bits: int_fast16_t, uint_fast16_t
  • Fastest integer with at least 32 bits: int_fast32_t, uint_fast32_t
  • Fastest integer with at least 64 bits: int_fast64_t, uint_fast64_t
  • Integer type with exactly 8 bits (optional): int8_t, uint8_t
  • Integer type with exactly 16 bits (optional): int16_t, uint16_t
  • Integer type with exactly 32 bits (optional): int32_t, uint32_t
  • Integer type with exactly 64 bits (optional): int64_t, uint64_t