Programming languages have several primitive data types to store and represent data. Types define the set of values a variable of type can take. Languages can be divided into several categories:

  • Strongly/weakly typed
    • Weakly-typed languages convert between unrelated types implicitly.
    • Strongly-typed languages don’t allow implicit conversions.
  • Statically/dynamically typed
    • Statically-typed languages do type checking (verifying/enforcing constraints) at compile-time.
    • Dynamically-typed languages do this at runtime.

Type systems

Common types

A brief list of common types in programming languages:

  • Integers
    • int, 32 bits
    • short, 16 bits
    • long, 32 bits
    • long long, 64 bits
  • Floating-point number
    • float, 32 bits, 7 digit precision
    • double, 64 bits, 15 digit precision (“double precision”)
    • long double, 19 digit precision
  • Text
    • char, 8 bits, in single quotes
    • string, for a size-varying string, in double quotes
  • Boolean values, bool (true, false)
  • And the void type

Note that the exact bit/byte length for a type will vary from machine to machine. Often some types are defined such that we can use a certain bit length, i.e., int8_t (or i8) for an 8-int signed integer.

Sub-pages