1. Write a Method That Takes a Positive Integer (<= 127) and Prints Its 2 S Complement

1. Write a Method That Takes a Positive Integer (<= 127) and Prints Its 2 S Complement

<p> 2’s complement exercises</p><p>1. Write a method that takes a positive integer (<= 127) and prints its 2’s complement representation.</p><p>2. Write a method that takes a negative integer (>= -128) and prints its 2’s complement representation.</p><p>3. On paper, do the following operations in binary (use what you did in the previous two exercises to get the binary representations of the numbers). Assume that the numbers are all stored in a byte (= 8 binary digits). a. 37 + 19 b. -37 – 19 c. -37 + 19 d. 100 + 50 (detect the overflow) e. -100 – 50 (detect the overflow) f. 9 * 11 g. -9 * -11 h. -9 * 11</p><p>4. Write the 16 digit binary representation of the following numbers a. 37 b. -37</p><p>5. In homework # 5, your computations should never overflow. The trick is to enlarge the binary representation of the numbers you are computing with to a size that guarantees the absence of overflow. Starting with an 8 bit size, practice with the following: a. 14 * 10 b. -14 * -10 c. 127 + 1</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    1 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us