You are on page 1of 4

Topic 1

- Character Encoding
- Number Systems
- Other Encodings

Character Encodings
! !

Recall: the main representation used in our computers are bits (binary
representation), which can be either 0 or 1.
!
Question: So how does the computer know what we are trying to input?
!

! !

Answer: Character encodings

Using binary representation, we can obtain different types of data by using


that character encoding. Here are some examples:
!
base n number systems
!

binary coded decimal

ASCII

Unicode

Gray Codes

Character Encodings
- base n number systems
! !

The base (radix) in a base n number system limits the number of possible
digits that a number can have. Here are some examples:
Name

Base

Possible Digits

Binary
Octal
Decimal
Hexadecimal

2
8
10
16

0, 1
0, 1, 2, 3, 4, 5, 6, 7
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

Character Encodings
- base n number systems
! !
! !

Counting in base n:
Given m bits, we can represent
2m different characters
from 0 to 2m!1
(Ex.1-1)

decimal
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

binary
0
1
10
11
100
101
110
111
1000
1001
1010
1011
1100
1101
1110
1111
10000

octal
0
1
2
3
4
5
6
7
10
11
12
13
14
15
16
17
20

hex.
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
10

Character Encodings
- base n number systems
! !

! !

A number is base n is denoted by xn


!
In particular 1010 and 102 are different numbers
This is why base Conversions between two different bases is so important in
number systems
Convert:

!
!

From base n to decimal (base 10) (Ex.1-2, 1.3)

From decimal (base 10) to base n (Ex.1-4, 1-5)

From base n to base m (n ! m) (Ex.1-6, 1-7)

Character Encodings
- base n number systems
! !

Addition in base n number systems (Ex.1-8)


!
is done exactly the same as in decimal (base 10)
!

! !

add from right hand side and carry when needed

Multiplication in base n is also done very similar to decimal (Ex.1-9)


!

multiply each row and add results

Character Encodings
- other encodings
! !
! !

! !

In general,
Besides base n number systems, there are other ways to encode a character
(for input, output, memory, etc.)
!
BCD (Binary Coded Decimal)
!

ASCII (American Standard Code for Information Exchange)

Unicode

BCD - includes 4 bits, codes 10 decimal digits (Ex.1-10)


Decimal
BCD digit

0000 0001 0010 0011 0100 0101 0110 0111 1000 1001

! !

ASCII - includes 7 bits, codes 128 characters (table 1-5 in textbook)

! !

Unicode - extends ASCII to 32 bits: 4,294,967,296 different characters


http://www.unicode.org/charts/
http://macchiato.com/unicode/chart/

! !

Gray Codes - next logical character differs by only one bit

ASCII table
B6 B5 B4
B3 B2 B1 B0

000

001

010

011

100

101

110

111

0000

null

dle

sp

0001

soh

dc1

0010

stx

dc2

0011

etx

dc3

0100

eot

dc4

0101

enq

nak

0110

ack

syn

&

0111

bel

etb

1000

bs

can

1001

ht

em

1010

lf

sub

1011

vt

esc

1100

ff

fs

<

1101

cr

gs

1110

so

rs

>

1111

si

us

del

You might also like