Data Types
In order to run commands and instruct the computer to work on a task we need to provide it information. For eg. instructing a computer to add two numbers assumes that the computer has the ability to store these two numbers and also the result of the summation. This infrastructure that allows computers to remember/store values in its system is called memory.
Information could be of many types:
- They could be numbers such as decimal values, fractions, etc.
- They could be names or alphanumeric (combination of alphabets and numbers) values.
- They could be something that indicates a state: eg. on or off, true or false
- They could also be customized data - such as a combination of the above. eg. Employee details which itself has employee id, employee name, address, etc.
Since there are so many possible data types, what does that mean for programming languages and computers? Can computers store infinite data?
Programming languages and computers are in general constrained by the amount of memory it has available to run instructions. Most languages provide a predefined set of data types and the ability to create custom data types. We will visit custom data types in another article.
The predefined set of data types that allow programmers to store data and create new data types are often known as primitive data types. They are built into the language. Most primitive data types consist of the following:
Integers (Whole numbers) : eg. 1, -1, 0, 100
Floating Point values (Real numbers): eg. 1.0, -1.5, 100.23
String (Character Sequences): eg. David, Y2K, pass123 :P
Boolean (Logical State): eg. true, false
No value: represents an absence of data (empty)
In the next article we will see how to store values and use these data types.