Number Systems Exercises: Binary and Hexadecimal Arithmetics, Lecture notes of Number Theory

Exercises on binary and hexadecimal number systems, including addition, subtraction, multiplication, and conversion between binary, hexadecimal, and decimal. It covers topics such as two's complement, range of numbers, and binary fractions.

Typology: Lecture notes

2021/2022

Uploaded on 08/05/2022

hal_s95
hal_s95 🇵🇭

4.4

(655)

10K documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Number Systems
Exercises
Robin Hirsch
Exercises
1. 1010 + 1101Answer: 10111
2. 1011 + 111Answer: 10010
3. 1111 1010Answer: 101
4. 1110 101 Answer: 1001
5. 1101 ×101 Answer: 1000001
6. 1001 ÷101 Answer: 1r101 or 1.11001100 ... which we write 1.
.
110
.
0
7. What is the biggest binary number you can write with 5 bits? Answer:
31
8. What is the biggest binary number you can write with nbits? Answer:
2n1
9. Roughly, how many bits do you need to write the number nin binary?
Answer: roughly log2n, exactly log2(n+ 1)
10. Write 3
4in binary, using a “binary point” 0.??. Answer: 0.11
11. Write 2
3in binary. Answer: 0.101010 ... = 0.
.
1
.
0
12. Which fractions recur infinitely in binary and which terminate? Answer:
if demoninator of fraction in lowest form is power of 2 then it terminates,
else not.
Exercises
13. Convert the binary number 1101101111110101 to hex. Answer: DBF 5
14. Convert the hex number ABC 7 to binary. Answer: 101010110111
15. In hex, 2BF C + 54A7. Answer: 80A3
16. In hex, AC74 B3F.Answer: A135
17. If a number has k digits in hex, how many digits (bits) does it have in
binary? Answer: k
4
1
pf3

Partial preview of the text

Download Number Systems Exercises: Binary and Hexadecimal Arithmetics and more Lecture notes Number Theory in PDF only on Docsity!

Number Systems

Exercises

Robin Hirsch

Exercises

  1. 1010 + 1101Answer: 10111
  2. 1011 + 111Answer: 10010
  3. 1111 − 1010 Answer: 101
  4. 1110 − 101 Answer: 1001
  5. 1101 × 101 Answer: 1000001
  6. 1001 ÷ 101 Answer: 1r101 or 1. 11001100... which we write 1.

. 1 10^

. 0

  1. What is the biggest binary number you can write with 5 bits? Answer: 31
  2. What is the biggest binary number you can write with n bits? Answer: 2 n^ − 1
  3. Roughly, how many bits do you need to write the number n in binary? Answer: roughly log 2 n, exactly ⌈log 2 (n + 1)⌉
  4. Write 34 in binary, using a “binary point” 0.??. Answer: 0. 11
  5. Write 23 in binary. Answer: 0. 101010... = 0.

. 1

. 0

  1. Which fractions recur infinitely in binary and which terminate? Answer: if demoninator of fraction in lowest form is power of 2 then it terminates, else not.

Exercises

  1. Convert the binary number 1101101111110101 to hex. Answer: DBF 5
  2. Convert the hex number ABC7 to binary. Answer: 101010110111
  3. In hex, 2BF C + 54A7. Answer: 80A 3
  4. In hex, AC 74 − B 3 F. Answer: A 135
  5. If a number has k digits in hex, how many digits (bits) does it have in binary? Answer: k 4
  1. If a number has k digits in decimal, roughly how many digits does it have in binary? Answer: roughly (^) logk 2 10 ∼= k 3
  2. If a number has k digits base a, roughly how many digits does it have in base b? Answer: roughly (^) logkb a = k × logab

Exercises Write the following decimal numbers in eight bit two’s complement, do the addition/subtraction, convert your answer back to decimal.

  1. −3 ++^11 Answer: −3 = 11111101. So −3 ++^ 11 = 11111101 + 00001011 = 00001000
  2. +125 +−^40 Answer: 125 = 01111101, −40 = 11011000 so 125 +−^ 40 = 01010101 = 85
  3. +5 +−^7 Answer: 00000101 + 11111001 = 11111110 =−^2
  4. − 23 −−^ 18. Answer: 11101001 + 11101110 = 11010111 =−^41

For n bit two’s complement what is the range of numbers you can represent?

Answer: Biggest positive numer is 0

n− 1 ︷ ︸︸ ︷ 11... 1 = 2n−^1 − 1. Negative numbers go

down from −1 =

n ︷ ︸︸ ︷ 1... 11 down to 1

n− 2 ︷ ︸︸ ︷ 00... 0 1 =−^2 n−^1 −1. But negative numbers

can go one lower still: least negative number is 1

n− 1 ︷ ︸︸ ︷ 00... 0 =−^2 n−^1. So range of numbers is [− 2 n−^1 ,+^2 n−^1 − 1].

Exercises Write the following fractions in binary. Use one sign bit and four bits after the binary point.

  1. 58 Answer: 0. 1010
  2. − 58 Answer: negate previous answer, i.e. flip all bits and add one to lsb, so 1. 0110

Convert the following binary fractions to ordinary fractions.

    1. 1000 Answer: (^12)
    1. 0001 Answer: −^1516
    1. 1111 Answer: (^1516)
    1. 1111 Answer: −^161

What fractions can be represented as binary fractions with one sign bit and four bits after the binary point? Answer: [− 1 ,+ 15 16 ]