Data Representation Homework Exercise

Homework

1. Write a paseudocode algorithm when given a number X, outputs the binary equivalent. [3 marks]

2. using a similar method demonstrated in class today, show the 8bit twos complement subtraction of 7 and 6. [3 marks]

3. Show the octal representation of  6  and 3. [4 marks]

© 2023  Vedesh Kungebeharry. All rights reserved. 

Binary Manipulation

Conversions

Class:

  1. Teacher shows how to produce binary representations for the decimal numbers 6 and 3.

  2. Teacher shows how to convert binary to decimal and shows verifies the result 110 produces 6 and 3 produces 11.

Binary Addition

  • Teacher adds 6 (110) and 3 (11) and verifies the result

Binary Subtraction

  • Teacher subtracts 6 (110) and 3 (11) and verifies the result as 3 (11)

Sign And Magnitude

  • Teacher shows how the fixed point system is used with  the MSB used to represent the sign, 0 for +ve, 1 for –ve



Twos complement

  • Show the +ve representation for 6 and 3

  • Show –ve representation of 6 and 3 (Using flip_+1 and copy+1 methods)
    • Copy method :
      • Going from right to left, copy all digits up to and including the first 1.
      • Filp the remaining bits.

  • Verify that 6-3 is equivalent to 6 + (-3 ) for an 8 bit two’s complement system.


In twos complement the MSB is taken to be -ve

Exercise – The Largest and Smallest magnitude twos complement numbers using 4 bits

Using a 4 bit twos complement system, what’s the

  1. Largest +ve number ,
  2. Lowest  -ve number

That can be represented?

© 2023  Vedesh Kungebeharry. All rights reserved.