• Everything in a computer memory is a bit (0 or a 1)
• 8 bits = 1 byte
• The byte is the smallest addressable chunk of memory on modern machines
• Machines are limited in how much memory they can possibly have by their address space size
• Example: most PC's are 32-bit machines, which means that there are at most 2^32 bytes of memory on the machine (about 4 GBytes)

Storing programming statements

• Every statement in a program is translated (by the compiler) into one or more machine instructions
• The possible machine instructions depend on the type of machine used (Intel, Sun, Apple)
• On a typical Windows machine with an Intel CPU, each instruction takes up between 1 and 9 bytes
• These instructions are stored in contiguous memory somewhere in the address space

Storing data

• Each data type in C has its own internal representation
• `int`: 32-bit binary number
• `long`: 32-bit or 64-bit binary number (depends on the machine)
• `double`: we'll discuss its format next week
• `char`: ASCII encoding (or Unicode, which is an extension)

Using `printf` format strings to look at underlying representations of data

• %x will print any piece of data out in hexadecimal
• %p will print out a pointer
• Example:
```#include <stdio.h>

int main( ) {
int a = 28;
double b = 33333.555555;
char c = 'c';

printf("a: %d %x\nb: %4.1f %x\nc: %d %x\n",
a, a, b, b, (int) c, c);
}
```

Conversion between decimal, binary, and hex

In base 10, the nth digit from the right in the number represents the number of 10^n 's in the number

Example: `2538`

DigitOffset from the rightRepresents
808 * 10^0 = 8
313 * 10^1 = 30
525 * 10^2 = 500
802 * 10^3 = 2000

So the number is 8 + 30 + 500 + 2000 = 2538.

Converting from other bases to base 10 can be done in the same way. For example, in binary, each column represents a power of 2.

Example: `1001101`

DigitOffset from the rightRepresents
101 * 2^0 = 1
010 * 2^1 = 0
121 * 2^2 = 4
131 * 2^3 = 8
040 * 2^4 = 0
050 * 2^5 = 0
161 * 2^6 = 64

So the number is 1 + 0 + 4 + 8 + 0 + 0 + 64 = 37

Example of conversion from hex

• Base 16
• need 16 different "digits": 0-9, A-F (so F represents 15)
• Each column in a number represents a power of 16

Example: `0xA203`

DigitOffset from the rightRepresents
303 * 16^0 = 3
010 * 16^1 = 0
220 * 16^2 = 512
a310 * 16^3 = 40960

So the number is 3 + 0 + 512 + 40960 = 41475