You are on page 1of 4

TD : Numbers Encoding

Exercise 1 : Conversion into Decimal (base 10)

1010 10112
1 0000 0000 0000 0000 0000 0000 00002
45610
ABC8h
A 0000 0000h

Exercise 2 : Base conversion


Complete the following Table :
Number

Base 2 (binary)

Base 8 (Octal)

Base 10 (Octal)

Base 16
(Hexadecimal)

0010 11012
000378
55510
A2h

Exercise 3: Miscellaneous Conversion


Convert the decimal fractional number .334 into binary

Using the base 2 with 16 bit precision


Using the base 16 with 16 bit precision (note: 1 hexadecimal digit = 4 bits)
Using the base 256 with 32 bit precision (how many bits does a 256 base digit has?)

Exercise 4: Sequence of bytes (8-bit packets)


Consider the following sequence of bytes:
01101111 01001111 00110000 00110010 11011101 11101111 11001110 11100100
Give the interpretation of each of these bytes while considering that they represent:

The one byte positive (unsigned) integers coded in binary


The one byte signed integers coded in binary (using 2s complement for negative values)
The two bytes signed integers coded in binary (using 2s complement for negative values)
A sequence of bits to represent a coded text using Huffman codes whose values are given as:
a :11 b:010 c:011 d:100 e:00 f :1010 et g :1011

Exercise 5: Positive and negative integers

We decide that the numbers are coded into binary using 8 bits. The negative numbers are
coded using 2s complement.

Give the binary and hexadecimal equivalents of -1, 40, -33, 127, -128
Can we represent 129? -129? Why? If yes, How?
Give the decimal values for the following bytes while considering the numbers to be (i) signed
(2s complement for negative numbers) integers, (ii) unsigned integers
12h A1h 9Ch 80h

Exercise 6: Floating point numbers (for help use course slides)

Convert the number into decimal whose binary IEEE 754 float (32 bits) value is given as:
|1|10000101|10101011010000000000000|. The bars are used to help the separation of different
parts (i.e. sign, exponent and mantissa)
Convert 521.625 into IEEE 754 on 32 bits.
Same question as the first part with |0|00000000|11010000000000000000000|.

Exercise 7: Basics of encoding with ASCII

From ASCII table, we know that A=65 and a=97, what is the difference between capital
and small letters.
In ASCII, the numeric characters have values 48 to 57 i.e. 0=48 and 9=57. How can we get
the numerical value of a character representing the number.
Extension to a sequence of characters: Give a formulae to get convert a sequence of
characters 123 into a numerical decimal value 123.

Table of ASCII codes (8-bit)


Dc

Hexa

ASCII

Dc

Hexa

ASCII

Dc

Hexa

ASCII

00

43

2B

86

56

01

44

2C

87

57

02

45

2D

88

58

03

46

2E

89

59

04

47

2F

90

5A

05

48

30

91

5B

06

49

31

92

5C

93

5D

5E

07

50

32

08

51

33

94

09

52

34

95

5F

10

0A

53

35

96

60

11

0B

54

36

97

61

12

0C

55

37

98

62

13

0D

56

38

99

63

14

0E

57

39

100

64

15

0F

58

3A

101

65

16

10

59

3B

102

66

17

11

60

3C

<

103

67

18

12

61

3D

104

68

19

13

62

3E

>

105

69

20

14

63

3F

106

6A

21

15

64

40

107

6B

22

16

65

41

108

6C

23

17

66

42

109

6D

24

18

67

43

110

6E

25

19

68

44

111

6F

26

1A

69

45

112

70

27

1B

70

46

113

71

28

1C

71

47

114

72

29

1D

72

48

115

73

30

1E

31

1F

32

20

33

21

34
35

73

49

116

74

74

4A

117

75

75

4B

118

76

76

4C

119

77

22

"

77

4D

120

78

23

78

4E

121

79

36

24

79

4F

122

7A

37

25

80

50

123

7B

38

26

&

81

51

124

7C

39

27

'

82

52

125

7D

40

28

83

53

126

7E

127

7F

41

29

84

54

42

2A

85

55

ASCII Dc

Dc

Hexa

ASCII

Dc

Hexa

128

80

171

AB

129

81

172

AC

130

82

173

131

83

174

132

84

133

85

134
135

Hexa

ASCII

214

D6

215

D7

AD

216

D8

AE

217

D9

175

AF

218

DA

176

B0

219

DB

86

177

B1

220

DC

87

178

B2

221

DD

136

88

179

B3

222

DE

137

89

180

B4

223

DF

138

8A

181

B5

224

E0

139

8B

182

B6

225

E1

140

8C

183

B7

226

E2

141

8D

184

B8

227

E3

142

8E

185

B9

228

E4

143

8F

186

BA

229

E5

144

90

187

BB

230

E6

145

91

188

BC

231

E7

146

92

189

BD

232

E8

147

93

190

BE

233

E9

148

94

191

BF

234

EA

149

95

192

C0

235

EB

150

96

193

C1

236

EC

151

97

194

C2

237

ED

152

98

195

C3

238

EE

153

99

196

C4

239

EF

154

9A

197

C5

240

F0

155

9B

198

C6

241

F1

156

9C

199

C7

242

F2

157

9D

200

C8

243

F3

158

9E

201

C9

244

F4

159

9F

202

CA

245

F5

160

A0

203

CB

246

F6

161

A1

204

CC

247

F7

162

A2

205

CD

248

F8

163

A3

206

CE

249

F9

164

A4

207

CF

250

FA

165

A5

208

D0

251

FB

166

A6

209

D1

252

FC

167

A7

210

D2

253

FD

168

A8

211

D3

254

FE

169

A9

212

D4

255

FF

170

AA

213

D5

You might also like