CS101 Lect11 BinaryNumbers PDF
CS101 Lect11 BinaryNumbers PDF
Number Systems
and Binary Numbers
Aaron Stevens
14 February 2011
1
3
2
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?
Numbers
Natural Numbers
Zero and any number obtained by repeatedly adding
one to it.
Negative Numbers
A value less than 0, with a – sign
3
Numbers
Integers
A natural number, a negative number, zero
Rational Numbers
An integer or the quotient of two integers
7
3
Numbering Systems
A numbering system assigns meaning to the
position of the numeric symbols.
642
8
4
4
Numbering Systems
It depends on the numbering system.
9
5
Positional Notation
Continuing with our example…
642 in base 10 positional notation is:
5
Positional Notation
642 = 63 * 102 + 42 * 101 + 21 * 100
B is the base
As a general form:
12
6
Binary Numbers
Digital computers are made up of electronic
circuits, which have exactly 2 states: on and off.
13
9
Binary Numbers
Decimal is base 10 and has 10 digits:
0,1,2,3,4,5,6,7,8,9
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. 14
9
7
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
15
22
1011bin = 8 + 0 + 2 + 1 = 11dec
16
8
Converting Binary to Decimal
What is the decimal equivalent of the binary
number 01101110?
17
13
9
Converting Binary to Decimal
Try another one. What is the decimal
equivalent of the binary number 10101011?
19
13
10
Converting from Decimal
to Other Bases
Algorithm (process) for converting number
in base 10 to other bases
11
Converting Decimal to Binary
Now you try one. What is the binary
equivalent of the decimal number 201?
23
201dec = 1 1 0 0 1 0 0 1bin
24
12
Binary and Computers
Byte
8 bits – a common unit of computer memory.
Word
A computer word is a group of bits which are passed
around together during computation.
The word length of the computer’s processor is how many
bits are grouped together.
• 8-bit machine (e.g. Nintendo Gameboy, 1989)
• 16-bit machine (e.g. Sega Genesis, 1989)
• 32-bit machines (e.g. Sony PlayStation, 1994)
• 64-bit machines (e.g. Nintendo 64, 1996)
25
23
26
13
Binary, Hexadecimal, Decimal
Each four bits
map to a hex digit.
Hexadecimal
prefix 0x????
No inherent value, just
means “treat as a hex
number”
0x94D3
27
Hexadecimal to Decimal
Convert each hex digit into 4 bits.
Convert binary to decimal.
Example:
0x94D3
= 1001 0100 1101 0011
= 215 + 212 + 210 + 27 + 26 + 24 +
21 + 20
= 32768 + 4096 + 1024 + 128 +
64 + 16 + 2 + 1
= 38099 (decimal)
28
14
Conversions Between
Number Systems
Try some!
http://www.mathsisfun.com/binary-decimal-
hexadecimal-converter.html
My phone number:
0x16FF96419
(or:
0001 0110 1111 1111 1001 0110 0100 0001 1001)
29
30
15
What You Learned Today
– Encoding: Symbols Represent Values
– Number Systems
– Binary Numbers, Bits, and Bytes
– Algorithms: converting binary to decimal
and vice versa
– Encoding: Hexadecimal
31
32
16
Want to learn more?
If you’ve read this far, maybe you’d like to
learn about other binary representations of
other types of numbers?
33
17