You are on page 1of 13

Chapter - Numbers and Data

Numbers

Base

Name

Data Unit

2
8
10
16

Binary
Octal
Decimal
Hexadecimal

Bit
Nibble
Digit
Byte

Data - non-numerical data, such as the letters A to Z

Number Systems
decimal

binary

octal

hexadecimal

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

0
1
10
11
100
101
110
111
1000
1001
1010
1011
1100
1101
1110
1111
10000
10001
10010
10011
10100

0
1
2
3
4
5
6
7
10
11
12
13
14
15
16
17
20
21
22
23
24

0
1
2
3
4
5
6
7
8
9
a
b
c
d
e
f
10
11
12
13
14

Number Conversions (binary to decimal)


26 = 64

25 = 32

24 = 16

23 = 8

1110001
1(26 ) =
1(25 ) =
1(24 ) =
0(23 ) =
0(22 ) =
0(21 ) =
1(20 ) =

64
32
16
0
0
0
1
113

22 = 4

21 = 2

20 = 1

Number Conversions
(decimal to binary)

932
= 466.0
2

2(0.0) = 0

466
= 233.0
2

2(0.0) = 0

233
= 116.5
2

2(0.5) = 1

116
= 58.0
2

2(0.0) = 0

58
= 29.0
2

2(0.0) = 0

29
= 14.5
2

2(0.5) = 1

14
= 7.0
2

2(0.0) = 0

7 = 3.5
2

2(0.5) = 1

3
= 1.5
2

2(0.5) = 1

1
= 0.5
2

2(0.5) = 1

done

1110100100

Digit Significance and Grouping


BYTE
MSB

WORD

LSB

MSB

0110 1011

LSB

0110 1011 0100 0010


most
significant
byte

least
significant
byte

Fractions in Binary
binary: 101.011
2

1 2 = 4

0 2 = 0

1 2 = 1

1 1
= 4 + 0 + 1 + 0 + + = 5.375 decimal
4 8

0 2 = 0

1
2
1 2 =
4

1
3
1 2 =
8

Boolean Operations on Binary Numbers


Name

Example

Result

AND
OR
NOT
EOR
NAND
shift left
shift right
etc.

0010 * 1010
0010 + 1010
0010
0010 eor 1010
0010 * 1010
111000
111000

0010
1010
1101
1000
1101
110001 (other results are possible)
011100 (other results are possible)

Negative Binary Integers


Type

Description

Range for Byte

unsigned

binary numbers can only have positive values.

0 to 255

signed

the most significant bit (MSB) of the binary number


is used to indicate positive/negative.
negative numbers are represented by complimenting
the binary number and then adding 1.

-127 to 127

2s compliment

decimal
2
1
0
-1
-2

-128 to 127

binary byte

METHOD FOR MAKING A NEGATIVE NUMBER

00000010
00000001
00000000
11111111
11111110

1. write the binary number for the positive


for -30 we write 30 = 00011110
2. Invert (compliment) the number
00011110 becomes 11100001
3. Add 1
11100001 + 00000001 = 11100010

Binary Arithmetic
00000001 = 1
+ 11111111 = -1

00000001 = 1
+ 11111110 = -2

00000010 = 2
+ 11111111 = -1

C+00000000 = 0

11111111 = -1

C+00000001 = 1

ignore the carry bits

01111111 = 127
+ 00000011 = 3
10000010 = -126
C=0
O = 1 (error)

10000001 = -127
+ 11111111 = -1

10000001 = -127
+ 11111110 = -2

10000000 = -128
C=1
O = 0 (no error)

01111111 = 127
C=1
O = 1 (error)

Hexadecimal

163 = 4096

162 = 256

161 = 16 160 = 1
f8a3

15(163 ) = 61440
8(162 ) = 2048
10(161 ) =
160
0
3(16 ) =
3
63651
5724
= 357.75
16

16(0.75) = 12 c

357
= 22.3125
16

16(0.3125) = 5

22
= 1.375
16

16(0.375) = 6

1
= 0.0625
16

16(0.0625) = 1

165c

BCD (Binary Coded Decimal)

1263
0001 0010 0110 0011

decimal
BCD

60
61
62
63
64
65
66
67
68
69
6A
6B
6C

01100000
01100001
01100010
01100011
01100100
01100101
01100110
01100111
01101000
01101001
01101010
01101011
01101100

ASCII

96
97
98
99
100
101
102
103
104
105
106
107
108

binary

@
A
B
C
D
E
F
G
H
I
J
K
L

hexadecimal

binary
01000000
01000001
01000010
01000011
01000100
01000101
01000110
01000111
01001000
01001001
01001010
01001011
01001100

decimal

40
41
42
43
44
45
46
47
48
49
4A
4B
4C

ASCII

64
65
66
67
68
69
70
71
72
73
74
75
76

hexadecimal

decimal

ASCII (American Standard Code for Information Interchange)

a
b
c
d
e
f
g
h
i
j
k
l

Parity
data
bits

parity
bit

Odd Parity

10101110
10111000

1
0

Even Parity

00101010
10111101

0
1

Checksum
DATA

CHECKSUM

124
43
255
9
27
47
505

Grey Code
decimal

gray code

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

0000
0001
0011
0010
0110
0111
0101
0100
1100
1101
1111
1110
1010
1011
1001
1000

You might also like