List of data types

From FIRSTwiki

Jump to: navigation, search

There are several basic data types, listed below:

Numeric

Numeric data types come in 2 variaties: Integral and Floating-point. You can specify either by using the signed and unsigned keywords.

Integers

Can only contain integers. They are signed by default.

  • char - 1 byte (8 bits) long, range: 0 - 255 unsigned (-128 - 127 signed)
  • int - 2 bytes (16 bits), 0 - 65,535 (-32,768 - 32,767)
  • short - same as int
  • short long - 3 bytes (24 bits), 0 - 16,777,215 (-8,388,608 - 8,388,607)
  • long - 4 bytes (32 bits), 0 - 4,294,967,295 (-2,147,483,648 - 2,147,483,6)

Decimals

Also known as Floating-point, they can contain fractional numbers. They are stored in scientific notation. [citation needed]
Note: the processor in the controllers does not have a floating point unit. Using floating-point can bog it down.

  • float - 4 bytes (32 bits)
    • Exponent range: -126 - 128
    • Overall range: \pm 2^{-126} \approx 1.17549435 * 10^{-38} \rightarrow \pm 2^{128} * (2 - 2^{-15}) \approx 6.80564693 * 10^{38} (and 0)
  • double - same as float
Personal tools