A **programming data type** is a classification of the type of data that a variable or object can hold in computer programming. Data types are an important factor in all computer programming languages, including C#, C++, JavaScript, and Visual Basic. When programmers develop computer software, both desktop and web-based, data types must be assigned and applied correctly, to guarantee proper outcome and an error-free program.

In programming, a data type is a categorisation that specifies what type of operation can be applied to it without resulting to an error.

The data type determines which operations can be safely executed to develop, transpose and apply the variable in another computation. When a programming language needs a variable to be used only in ways that follow its data type, that language is said to be strongly typed.

This restricts errors, because while it is reasonable to ask the computer to multiply a float by an integer (3.4 x 3), it is unreasonable to ask the computer to multiply a float by a string (3.4 x Sam). When a programming language lets a variable assume a different data type, the language is said to be weakly typed.

Strongly typed and weakly typed programming languages are misconceptions. There is a type safety concept where a programming language intimidates or restricts type error.

## Common Data Types

**Integer**– is a whole number that can have a positive, negative or zero value. It cannot be a fraction nor can have decimal places. It is commonly used in programming especially for increasing values. Addition, subtraction and multiplication of two integers results to an integer. But division of two integers may result to an integer or a decimal. The resulting decimal can be rounded off or truncated to produce an integer.**Character**– refers to any number, letter, space or symbol that can be entered in a computer. Each character occupies one byte of space.**String**– is used to represent text. It is composed of a set of characters that can have spaces and numbers. Strings are enclosed in quotation marks to identify the data as string and not a variable name nor a number.**Floating Point Number**– is a number that contains decimals. Numbers that contain fractions are also considered as floating-point numbers.**Array**– contains a group of elements which can be of the same data type as an integer or string. It is used to organise data for easier sorting and searching of related set of values.**Varchar**– as the name implies is variable character as the memory storage has variable length. Each character occupies one byte of space plus 2 bytes for length information.

*Note: Use Character for data entries with fixed length, like phone number. Use Varchar for data entries with variable length, like address.*

**Boolean**– is used for creating true or false statements. To compare values the following operators are being used: AND, OR, XOR, and NOT.

Boolean Operator |
Result |
Condition |
---|---|---|

x AND y | True | If both x and y are True |

x AND y | False | If either x or y is False |

x OR y | True | If either x or y, or both x and y are True |

x OR y | False | If both x and y are False |

x XOR y | True | If only x or y is True |

x XOR y | False | If x and y are both True or both False |

NOT x | True | If x is False |

NOT x | False | If x is True |

**Date, Time and Timestamp**– these data types are used to work with data containing dates and times.

Date Type |
Value |
---|---|

DATE | Year, Month and Day |

TIME | Hour, Minute and Second |

TIMESTAMP | Year, Month, Day, Hour, Minute, Second and Microsecond |