CSCI 150, Spring 2003

Home | | Course Schedule | | Assignments | | Lecture Notes

Binary representations.

1. Types of information
We use computers to represent many different types of information:

Computers do all their computations using digital circuits, which can only represent things with 1's and 0's.

By combining 1's and 0's in different patterns and sequences, can represent complex pieces of information and compute solutions to difficult problems.

2. Counting in Base 2 (binary)
Base 10 uses 10 digits - 0 through 9.
Base 2 uses only 2 digits - 0 and 1

Decimal
(Base 10)
Binary
(Base 2)
0 0
1 1
2 10
3 11
4 100
5 101
6 110
7 111
8 1000
9 1001
10 1010

In base 10, each place represents a power of 10:

In base 2, each place represents a power of 2:

3. Converting from Decimal into Binary:
Divide repeatedly by 2. Put remainders in reverse order:

Therefore, 25 is 11001 in base 2

4. Hexadecimal is Base 16

Converting Binary to Hexadecimal:
Each group of 4 binary digits (bits) is 1 hexadecimal digit.

5. Binary arithmetic
a) Representing positive and negative numbers:
Signed Magnitude:

One's complement:

Two's complement:

Adding numbers:
Convert to two's complement and add:

Subtracting numbers:
Convert to two's complement and add:

Potential problems:

6. Representing real numbers
32 bit representation:

0 1000011 101010000000000000000000