Definition

data type

A data type, in programming, is a classification that specifies which type of value a variable has and what type of mathematical, relational or logical operations can be applied to it without causing an error. A string, for example, is a data type that is used to classify text and an integer is a data type used to classify whole numbers.

Data Type

Used for

Example

String

Alphanumeric characters

hello world, Alice, Bob123

Integer

Whole numbers

7, 12, 999

Float (floating point)

Number with a decimal point

3.15, 9.06, 00.13

Character

Encoding text numerically

97 (in ASCII, 97 is a lower case 'a')

Boolean

Representing logical values

TRUE, FALSE

The data type defines which operations can safely be performed to create, transform and use the variable in another computation. When a program language requires a variable to only be used in ways that respect its data type, that language is said to be strongly typed. This prevents errors, because while it is logical to ask the computer to multiply a float by an integer (1.5 x 5), it is illogical to ask the computer to multiply a float by a string (1.5 x Alice). When a programming language allows a variable of one data type to be used as if it were a value of another data type, the language is said to be weakly typed.

Technically, the concept of a strongly typed or weakly typed programming language is a fallacy. In every programming language, all values of a variable have a static type -- but the type might be one whose values are classified into one or more classes. And 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 run-time. The extent to which a programming language discourages or prevents type error is known as type safety.

 

This was last updated in November 2016

Continue Reading About data type

Dig Deeper on Service-oriented architecture (SOA) development

PRO+

Content

Find more PRO+ content and other member only offers, here.

Join the conversation

2 comments

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

If the data type defines what operations can be performed, why do so many errors occur at run-time instead of when the code is compiled or interpreted?
Cancel
This knowledge is useful 4 beginners to learn vb
Cancel

-ADS BY GOOGLE

File Extensions and File Formats

Powered by:

SearchSoftwareQuality

SearchCloudApplications

SearchAWS

TheServerSide

SearchWinDevelopment

Close