Data Types

In programming data types, also sometimes referred to as types, are the types of data that the language can interprete. Every language can potentially, and more than likely will, support other data types but this guide is going to go over the most basic types that are used by most programming languages.

Some of the most common data types are the following:

  • int or integer: The int, sometimes also referred to as integer, data type is used to store numeric values. Some languages have a maximum value this data type can store but as a general rule int can store any positive or negative number within the limits of your chosen language.
  • long: The long data type is used to store a larger number than int can store (if your programming language has a limit). It is important note that a long data type is normally a 64 bit memory address as opposed to int which is normally a 32 bit memory address. With that in mind long should only be used when an int is not adequate.
  • float: The float data type is used to store floating point numbers or numbers with a decimal value. Some examples of what we can store in a float could be: 1.2, 24.57, or 27894.02832. Some programming languages handle float differently, but a good general rule is that you won't be able to directly convert a float data type to an int without rounding the value to the nearest whole number although some programming languages may do this for you automatically. Another tip to note is that most languages that do have a limit on how much information can be stored in a float data type. For a bigger number most languages that have a limit on float will also hava double data type.
  • double: The double data type is used like to store a larger value number than int can store (if your programming language has a limit) and normally also supports decimal values like a float. Its important to note that most of the time if a programming language has a double data type it is a 64 bit memory address as opposed to int or float which is normally a 32 bit memory address. With that in mind a double should only be used when an int or float is adequate.
  • char: The char data type is used to store a single character. Some programming languages don't have a specific data type for characters and instead opt to just support strings. Every programming language can potentially handle the char data type differently but a good general rule to follow is that char can contain a single character that can be letters (upper and lower case), a numerical digit, or common punctuation marks (. or -). Most commonly programming languages denote the char data type with a single quote: 'e'. It is important to note that although you can store digits in a char data type you will not be able to do calculations with it in most programming languages as you are actually storing a charater of say 5, not a value of 5.
  • string or String: The string data type, sometimes referred to as String, can be thought of as a "string" (pun intended) of char data types. Again some programming languages treat string differently and have different limits as to what can be stored in a string. A good general rule for strings is that it can support whatever your language of choices supports for char. Most commonly programming languages denote a string with double quotes: "This is a string!".
  • bool or boolean: The bool data type, sometimes referred to as boolean, can be thought of as a data type that is either true or false. Although every programming language can treat bool different most of them allow you to store either true, false, 1, or 0, with 1 being treated as true and 0 being treated as false.
This page was last updated: 2021-10-24 Sun 04:52:36. Source