Become a Nerd! Basic Data Type Cheat Sheet

image1 (1)

A basic understanding of data types is essential in computer science and programming. You have to know what kind of data you are dealing with in order to know what to do with it! Below you will find a very basic breakdown of the different data types and what kind of data they represent. The specifics of data types used by different languages can vary slightly, but the basics remain the same.

Char

A char (short for character) is essentially any single character.

Here are 3 chars together: A@1.

A char can vary in the size that it requires in memory, but a common trait across all languages is that it is a very small datatype. Chars can be put together to form a string, which is a fancy term for a group of chars. A word is a string, as is a sentence.  This paragraph is a string as well.

Int

An int is any whole number. It can be negative, but it can never be a fraction. The size of the int determines how many bytes it takes up, but even a very large int is relatively small, clocking in at 8 bytes. A whole number is always going to be an int 1 is an int, and so is 154,512,514,541,165.

Boolean

True or False. This is about as simple as it gets. Often represented with a 0 for false, 1 for true. Boolean values are quite useful when it comes to conditional statements. What is a conditional statement? That’s for another time.

Floating point

So, if an int is a whole number we are going to need something to represent a decimal, right? Floating point numbers represent numbers with decimals. Their accuracy is not 100%, because it is an approximation of a “real” number. The decimal can be scaled to two, ten  or sixteen places so if the actual number has more numerals after the decimal then it will not be precise. This is not usually a hindrance for most calculations but it needs to be considered. The number of digits is variable for a floating point number, which may not always be what is needed so we have …

Fixed point

A fixed point number can be a decimal and will always be represented to a specified number of decimal places. Generally in programming “fixed” value data types are going to be a little bit quicker to process because the computer knows exactly what it is looking for. If you know that a number is always going to be represented to the fourth numeral after the decimal then Fixed Point is the way to go.