In this section, we discuss the different types of data you can have and the best ways to store them in your programs.

Transcript

So, let's look at the diverse types of data we can use. Now all data in a computer is stored as 1s and 0s in memory. So, whether it's words, pictures, sound, it's how we group and interpret that binary that gives it meaning.

So, if we look at the workshop page for this section, I've made a table of the diverse types of data you can use. So, for instance; if I wanted to store a word, a word is made up of individual characters and we can store characters inside a chart variable. But if I was to store that data inside a different type, it could have a different meaning. We can also interpret that character as a number, so if we wanted to say lowercase a plus 1 equals log case B, we can do that. Now the types in the table are sorted into two distinct categories there are integer types and floating-point types. Integer types can only hold whole numbers, whereas the floating-point types can store real numbers and fractions, to varying levels of precision. For instance, the float, in this case, is 32 bits and it can hold roughly seven to eight decimal places. Whereas a double, which is also known as a double precision floating point number, can hold roughly 15 to 16 decimal places.

I say float and double, can have those sizes in this case because in some circumstances depending on your platform and compiler the size of data types can change. For instance, on the Raspberry Pi with the GCC compiler, the long double is 64 bits, just like the double. Now if you want to see what sizes are available on your platform at the bottom of the section, I've written some code that you should be able to copy and paste into a C file and when you run it, it will give you the same table as what I've created above. You may notice when looking at this table that some of the types have unsigned at the beginning, this means that they can only hold positive values. Whereas the other types known as "signed" types, can hold negative numbers, but their maximum value is halved.

Now these aren't the only types available there are others and in a later chapter, we'll be going through how to make your own types. But these really are the fundamental ones and the ones we'll be using most often.

Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.