A data type is a classification for the kind of information that can be stored in a variable. Data types are either classified as an integer, long, float etc. and there are many different ones to choose from based on what you will need them for.
A string is also considered to be a data type but it has its own classifications like text strings or binary strings.
If you’re looking to store numbers with decimal points then you’ll want to go with floats because they allow more precision than integers do since they have more digits after the decimal point.
The most popular programming languages only really support these main data types: boolean, int, float character, and string. There are many different types depends on programming languge or database engine.
Examples of Common Data Types
- Boolean: True, False, 1, 0
- Character: a, A, z, Z
- Date: 08/26/2021
- Double: 1.22469021379123E412
- Float: 2.516
- Integer: 9999
- Long: 987654321
- String: “hello world”
- Void/Null: no data
How These Data Types Are Used?
Booleans are used to indicate whether a statement is true or false. It is used in alot of logical expressions.
The basic difference between a string and an integer is that a string is used to store text while integers can be numbers without any fractional digits. You can store information like the current year, your height, weight or anything else like that in sting but if you want to do math with it then you need to use an integer to do that.
The most common use of a string is something like your name, address or anything else with text in it. Since strings store information as text you can combine different texts together to get the info you need but if you just want to store numbers then they are stored as integers and not strings.
When you’re trying to decide what data type you should use it’s really up to you but just make sure that whatever you pick, they have enough digits in them for the numbers that will be stored. For example, an integer can only store numbers without decimal points so it wouldn’t be a good idea to store something like your age or weight with one of those numbers since people can get up to a 100 years old and weights can be as low as 0.2 lbs.
If you’re planning on storing a large amount of data then it’s best to use something like an array so that the information will stay organized in one place instead of getting broken up into different variables all over your program.