Comments by "Lawrence D’Oliveiro" (@lawrencedoliveiro9104) on "Scott Manley" channel.

  1. 4
  2. 4
  3. There are 3 well-known ways of representing signed integers using binary notation: sign-magnitude, ones-complement, and twos-complement. Sign-magnitude is probably the first one that anybody would think of: reserve one bit for the sign, and use the rest of the bits to represent the magnitude. Let’s say we have 5-bit integers, for simplicity. After reserving one bit for the sign, we have 4 bits left for the magnitude. If we put the sign bit at the left and use 0 for positive and 1 for negative, then +3 could be represented as 00011 while -3 would be 10011 Addition and subtraction requires complicated logic to extract the sign and magnitude, and do different things with the magnitudes depending on whether the signs are same or different, then deciding what sign to attach to the result. In ones-complement, +3 is represented the same as before, but instead of negating by flipping only the sign bit, we flip all the bits. So -3 becomes 11100 Note that complementing applies to zero as well. Thus, both 00000 and 11111 represent zero. The latter can be considered to be “negative zero”, since its sign bit is 1. When we add +3 and -3: 00011 +11100 =11111 which is indeed one of the representations of zero. Twos-complement gets rid of the redundant representation of zero, by redefining negation to be done by flipping all the bits, then adding 1. Thus, -3 is now represented as 11101 So adding +3 and -3: 00011 +11101 =100000 And throwing away the 1 that has gone into the 6th bit (because we can only represent 5 bits) gives zero, as expected.
    4
  4. 3
  5. 3
  6. 3
  7. 3
  8. 3
  9. 3
  10. 3
  11. 3
  12. 3
  13. 3
  14. 3
  15. 3
  16. 3
  17. 3
  18. 3
  19. 3
  20. 3
  21. 3
  22. 3
  23. 3
  24. 3
  25. 3
  26. 3
  27. 3
  28. 3
  29. 3
  30. 3
  31. 2
  32. 2
  33. 2
  34. 2
  35. 2
  36. 2
  37. 2
  38. 2
  39. 2
  40. 2
  41. 2
  42. 2
  43. 2
  44. 2
  45. 2
  46. 2
  47. 2
  48. 2
  49. 2
  50. 2