Lectern

Search

Search IconIcon to open search

Data typing

Last updated Oct 13, 2022

The process of assigning a type to a particular variable or value. Often done to: - dynamically allocate a certain amount of memory (for instance, double allocates twice as many bits as float); and - restrict operations (as some operations, like division, can only be done for certain types).

Different languages can have different data types, but the common few include:

Data typeUsed for
integerWhole numbers
floatNumbers with a floating point decimal
characterAny kind of character
stringA chain of characters
BooleanTrue or false values
list/arrayA collection of data types

In some low-level languages (e.g., the C family of languages), there may be additional data types to handle assigning different amounts of bits (usually 16, 32, and 64 bits). Common types include:

Data typeRelated data typeBit sizeAmount held
byteinteger8256 (0–255 unsigned, -128–127 signed)
shortinteger1665536 (0–65535 unsigned, -32768–32767 signed)
longinteger324294967296 (0—4294967295 unsigned, -2147483648–2147483647 signed)
doublefloat64