Skip to main content
Logo image

Section 18.1 Space Needed to Store Variables

We already have a pretty good idea that different data types take up different amounts of space in memory. For example, to store a character (char) all we need to do is store its ASCII code which, when represented in binary, fits into one byte. On the other hand, most integers (for example the number 999) need more than one byte to store them in binary 2’s complement. And recall that floats are stored in scientific notation as mantissa and exponent - lots of memory needed there. Let’s see how we can make this more precise.

If you cannot see this codecast, please click here.

Check Your Understanding Check Your Understanding

1.

Assuming that a variable of type double occupies 8 bytes in memory, how much space will be occupied by the variable doubleArray declared as follows:
double doubleArray[3];
  1. 8 bytes
  2. 24 bytes
  3. 32 bytes
  4. 3 bytes