Skip to the content of the web site.

Built-in Data Types

Next, we will look at built-in data types. All but the most trivial programs store and manipulate information on a computer. In your GENE 121 and MTE 140 courses, you learned how to store and manipulate data using C++. This is just a quick review of those features that overlap between C and C++, starting with variables.

To store information on a computer, it is ultimately necessary to convert the data into ones and zeros: a novel is converted into unicode characters, each of which is made up of sixteen bits while a photograph is approximated using a discretizations which is then approximated using the Fourier cosine transform, the coefficients of which are stored on the computer.

There are fewer than two dozen built-in data types: formats for information for which the library is already aware: these are to store characters, integers on restricted ranges, memory-related and real numbers on restricted ranges with restricted precision.

bool 8 bits
char8 bits0 to 256
signed char8 bits-128 to 127

A special wide character is available in the library wchar.h and the type is wchar_t. It is used for unicode characters.

short16 bits-32768 to 32767
unsigned short16 bits0 to 65535
int32 bits-2147483648 to 2147483647
unsigned int32 bits0 to 4294967295
long64 bits-9223372036854775808 to 9223372036854775807
unsigned long64 bits0 to 18446744073709551615
long long64 bits-9223372036854775808 to 9223372036854775807
unsigned long long64 bits0 to 18446744073709551615
float32 bits
double64 bits
long double128 bits
size_t64 bits0 to 18446744073709551615
ptrdiff_t64 bits