Skip to main content
Logo image

Chapter 5 Integers and Binary

Now that we have been introduced to variables and some common data types in C, such as int, float and char, it is important to get a glimpse into how variables are stored in computer memory. After all, the only thing a computer, at the very basic level understands is on and off (or 1 and 0). Given that insight, how is it possible to store an integer such as 20 using only zeros and ones? Or how about a decimal number such as 3.1415? Or a character such as ‘E’? In this chapter, we will learn about binary numbers, and how they are used to represent all data in the computer’s memory. We will learn the different conventions for representing positive and negative numbers in binary. We will also take a look at hexadecimal numbers (pretty much as a short-hand to binary), and how we can convert between all these different number representations.