data type

What is a data type?

In software programming, data type refers to the type of value a variable has and what type of mathematical, relational or logical operations can be applied without causing an error. For example, many programming languages use the data type string to classify text, integer to identify whole numbers and floating point to designate numbers with decimal points.

Data type Used for Examples
String Alphanumeric characters hello world
Integer Whole numbers 7
Float (floating point) Numbers with a decimal point 3.15
Character Encoding text numerically 97 (in ASCII, 97 indicates a lowercase a)
Boolean Representing logical values TRUE

The data type defines which operations can safely be performed to create, transform and use the variable in another computation. In most programming languages, variable values commonly possess a static type. However, the values of those static types can still exist within multiple variable classes. While some classes specify how the data type's value will be compiled or interpreted, there are other classes whose values are not marked with their class until runtime.

The extent to which a programming language discourages or prevents type error is known as type safety. When a programming language requires a variable to be used only in ways that respect its data type, that language is said to be strongly typed. If data types do not align -- such as trying to multiply an integer by a string -- a strongly typed language will likely prevent the program from running to avert potential operational errors.

Meanwhile, programming languages that allow a variable of one data type to be used as if it were a value of another data type are said to be weakly typed. While the program might be allowed to run, these data mismatches could cause eventual errors or crashes.

This was last updated in May 2023

Continue Reading About data type

Dig Deeper on Application development and design

Software Quality
Cloud Computing