# CS101 Lecture 11: Number Systems and Binary Numbers

## Preview text

CS101 Lecture 11: Number Systems and Binary Numbers
Aaron Stevens
8 February 2010
1
2
1

3
4
2

!!! MATH WARNING !!!
TODAY’S LECTURE CONTAINS TRACE AMOUNTS OF
ARITHMETIC AND ALGEBRA
(and that you probably won’t need them)
5
Overview/Questions
– What gives a number its value? – What is a number system? – I’ve heard that computers use binary
numbers. What’s a binary number? – What kind of numbers do computers store
and manipulate?
6
3

Numbers
Natural Numbers
Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645, 32
Negative Numbers
A value less than 0, with a – sign Examples: -24, -1, -45645, -32
72
Numbers
Integers
A natural number, a negative number, zero Examples: 249, 0, -45645, -32
Rational Numbers
An integer or the quotient of two integers Examples: -249, -1, 0, 3/7, -2/5
83
4

Numbering Systems
A numbering system assigns meaning to the position of the numeric symbols. For example, consider this set of symbols: 642 What number is it? Why?
94
Numbering Systems
It depends on the numbering system. 642 is 600 + 40 + 2 in BASE 10 The base of a number determines the number of digits (e.g. symbols) and the value of digit positions
10 5
5

Positional Notation
Continuing with our example…
642 in base 10 positional notation is:
6 x 102 = 6 x 100 = 600 + 4 x 101 = 4 x 10 = 40 + 2 x 10º = 2 x 1 = 2 = 642 in base 10

This number is in base 10

The power indicates the position of the number

11 6

Positional Notation
642 = 63 * 102 + 42 * 101 + 21 * 100

As a general form:
dn * Bn-1 + dn-1 * Bn-2

B is the base
+ ... + d1 * B0

n is the number of digits in the number

d is the digit in the ith position
in the number
12 7

6

What Would Pooh Do?
13
Binary Numbers
Digital computers are made up of electronic circuits, which have exactly 2 states: on and off. Computers use a numbering system which has exactly 2 symbols, representing on and off.
14 9 7

Binary Numbers
Decimal is base 10 and has 10 digits: 0,1,2,3,4,5,6,7,8,9
Binary is base 2 and has 2, so we use only 2 symbols:
0,1

For a given base, valid numbers will only contain the digits in that base, which range from 0 up to (but not including) the base.

15 9

Binary Numbers and Computers

A binary digit or bit can take on only these two values.

Low Voltage = 0 High Voltage = 1

all bits have 0 or 1

Binary numbers are built by concatenating a string of bits together. Example: 10101010

16 22

8

Positional Notation: Binary Numbers
Recall this general form:
dn * Bn-1 + dn-1 * Bn-2 + ... + d1 * B0
The same can be applied to base-2 numbers: 1011bin = 1 * 23 + 0 * 22 + 1 * 21 + 1 * 20 1011bin = (1 * 8) + (0 * 4) + (1 * 2) + (1 * 1) 1011bin = 8 + 0 + 2 + 1 = 11dec
17
Converting Binary to Decimal
What is the decimal equivalent of the binary number 01101110?
(you try it! Work left-to-right)
18 13
9

Converting Binary to Decimal
What is the decimal equivalent of the binary number 01101110?
0 x 27 = 0 x 128 = 0 + 1 x 26 = 1 x 64 = 64 + 1 x 25 = 1 x 32 = 32 + 0 x 24 = 0 x 16 = 0 + 1 x 23 = 1 x 8 = 8 + 1 x 22 = 1 x 4 = 4 + 1 x 21 = 1 x 2 = 2 + 0 x 2º = 0 x 1 = 0
= 110 (decimal) 19 13
Converting Binary to Decimal
Try another one. What is the decimal equivalent of the binary number 10101011?
(you try it! Work left-to-right)
20 13
10 