Agenda

loops, function basics, quiz1 review topics: operators, number systems

Notes

  • multiplication with hexadecimal numbers directly when in 2’s complement (8 * F213)

    • Solution

      • Since the given implementation is 2’s complement, if the hexadecimal term’s first character is anything between 8 and F (both inclusive), the given number would be negative.
      • In that case, one should first find the positive form of that number.
      • You can do this by subtracting each character from F and adding one to the result.
      • Now, with this positive form, you can just multiply the required number directly as you would in decimal multiplication.
      • Make sure you work the carry part correctly since this is hexadecimal and not decimal.
      • For example, if you do a C * 3, you would get 36, which is 16 * 2 + 4. Thus, you would write 4 below and carry over 2.
      • Once you get the product, make sure to convert it back to its negative form (if the original number was negative) by subtracting each character from F and adding 1 to the result. This will be your answer.
\[\\\]
  • Difference between i++ and (i)++

    • Solution:

      Read this