Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Number Systems
and Codes
Discussion D4.1
Number Systems
•
•
•
•
Counting in Binary
Positional Notation
Hexadecimal Numbers
Negative Numbers
Counting in Binary
Position:
8
BINARY
4
2
1
0
0
0
0
0
0
0
0
1
0
0
0
0
1
1
1
1
0
0
1
0
1
0
1
0
1
0
0
0
1
1
0
0
1
1
0
HEX
0
1
2
3
4
5
6
7
8
Counting in Binary
Position:
8
BINARY
4
2
1
1
1
1
1
1
1
1
1
0
0
0
0
1
1
1
1
0
1
0
1
0
1
0
1
0
0
1
1
0
0
1
1
HEX
8
9
A
B
C
D
E
F
Counting in Binary
BINARY
128 64
DEC
32 16
8
4
2
1
0
0
1
1
0
1
0
0
52
1
0
1
0
0
0
1
1
163
1
1
1
1
1
1
1
1
255
Positional Notation
N = P4P3P2P1P0
= P4b4 + P3b3 + P2b2 + P1b1 + P0b0
58410 = 5 x 102 + 8 x 101 + 4 x 100
= 500 + 80 + 4
= 584
Positional Notation
N = P4P3P2P1P0
= P4b4 + P3b3 + P2b2 + P1b1 + P0b0
Binary
101102 = 1 x 24 + 0 x 23 + 1 x 22 + 1 x 21 + 0 x 20
= 16 + 0 + 4 + 2 + 0
= 2210
Positional Notation
N = P4P3P2P1P0
= P4b4 + P3b3 + P2b2 + P1b1 + P0b0
Hex
3AF16 = 3 x 162 + A x 161 + F x 160
= 3 x 256 + 10 x 16 + 15 x 1
= 768 + 160 + 15
= 94310
Binary
Hex
0110 1010 1000
6
A
8
1111 0101 1100
F
5
C
Questions
What is the decimal value of 2435?
2x52+4x5+3
= 50+20+3
= 73
Negative Numbers
Subtract by adding
73
-35
38
10’s complement
Ignore carry
73
+65
138
Negative Numbers
10’s complement:
Subtract from 100
100
-35
65
Take 9’s complement and add 1
99
-35
64
+1
65
Negative Numbers
2’s complement:
Subtract from
100000000
01001101
10110011
Take 1’s complement and add 1
11111111
-01001101
10110010
+1
10110011
Finding 2’s Complement
Complement
remaining bits
0 1 0 1 1 0 0 0
1 0 1 0 1 00 0
2’s complement
Copy all bits
to first 1
Negative Number
Take 2’s Complement
7510 = 4B16 = 01001011
-7510 = B516 = 10110101
FF
-4B
B4
+1
B5
Negative Number
Take 2’s Complement
110 = 0116 = 00000001
-110 = FF16 = 11111111
12810 = 8016 = 10000000
-12810 = 8016 = 10000000
Table 2.2
Positive and Negative Binary Numbers
Signed decimal
-128
-127
-126
…
…
…
-3
-2
-1
0
1
2
3
…
…
125
126
127
Hex
80
81
82
…
…
…
FD
FE
FF
00
01
02
03
…
…
7D
7E
7F
Binary
10000000
10000001
10000010
…
…
…
11111101
11111110
11111111
00000000
00000001
00000010
00000011
…
…
…
01111101
01111110
01111111
Unsigned decimal
128
129
130
…
…
…
253
254
255
0
1
2
3
…
…
…
125
126
127
Signed Numbers
4-bit:
8H = -8 to 7H = +7
1000 to 0111
8-bit: 80H = -128 to 7F = +127
16-bit: 8000H = -32,768 to
7FFFH = +32,767
32-bit: 80000000H = -2,147,483,648 to
7FFFFFFFH = +2,147,483,647
Questions
What is the two’s complement of
00101100?
11010100
Questions
What hex number represents the
decimal number -40?
4010 = 2816
= 001010002
2’s comp
110110002
= D816
Gray Code
Note that the least significant bit
that can be changed without
repeating a value is the bit
that is changed
Binary
Gray Code
000
001
010
011
100
101
110
111
000
001
011
010
110
111
101
100
Binary-Coded Decimal (BCD)
Use 4-bit binary numbers 0000 – 1001 to represent
the decimal digits, 0 – 9.
Note that the six hex values A – F, 1010 – 1111, are
NOT valid BCD values.
Example:
10010101
represents the hex value 9516 = 14910
However, as a BCD number it represents the
decimal number 95.
Standard ASCII Codes
Standard ASCII codes
Dec
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Hex
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0
16
32
48
64
80
96
112
0
1
2
3
4
5
6
7
NUL
SOH
STX
ETX
EOT
ENQ
ACK
BEL
BS
HT
LF
VT
FF
CR
SO
SI
DLE
DC1
DC2
DC3
DC4
NAK
SYN
ETB
CAN
EM
SUB
ESC
FS
GS
RS
US
blank
0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
?
@
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
[
\
]
^
_
!
"
#
$
%
&
'
(
)
*
+
,
.
/
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
{
|
}
~
DEL