Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 2: Bit Twiddling Computers use a particular word size (measured in bits)

ID: 3746349 • Letter: P

Question

Problem 2: Bit Twiddling Computers use a particular word size (measured in bits) for representing integers. In the mid-1970s have word sizes of 16 bits were common A. How many distinct values can be encoded in a 16-bit word? Answer: Even back in those days most computers used a 2's complement representation for integers. In 2's complement notation, one negates a number by complementing each bit in its representation (i.e changing 0's to 1's and vice versa) and adding 1. By convention, we write 2's complement integers with the most-significant bit (MSB) on the left and the least-significant bit (LSB) on the right. Also by convention, if the MSB is 1, the number is negative; otherwise it's non-negative B. Assume a 16-bit 2's complement representation when answering the following questions. What's the binary representation for 0? For the largest positive integer that can be represented? For the most negative integer? What are the decimal equivalent for the largest positive and most negative integers? What do you get if you negate the largest negative integer (give both the binary and decimal values)? Answers 0 (binary) Largest positive (binary) Most negative (binary) Largest positive (decimal) Most negative (decimal) 2's complement of most negative (binary) 2's complement of most negative (decimal) C. Since writing strings of 16 bits gets tedious, it's often convenient to use hexadecimal notation where a single digit in the range 0-9 or A-F is used to represent adjacent groups of 4 bits (starting from the right). Give the corresponding 4-digit hexadecimal encoding for each of the following numbers Answers 1. 2. 3 4 5 6 7. 8 : 2048 : 1023 : 11281 10 :-1073110 :00000100001001002 : -409510 D. At first blush "Complementing each bit and adding 1" doesn't seem like an obvious way to negate a number. However, it should appear "obvious" after the following exercise : Enter 960910 in binary : Complement each bit of the binary number above : Compute the sum of the two numbers : What is the decimal equivalent of this 2's complment sum?

Explanation / Answer

A 16-bit integer can store 2^16 (or 65,536) distinct values. In an unsigned representation, these values are the integers between 0 and 65,535; using two's complement, possible values range from 32,768 to 32,767

A

2^16 or 65536 values

B

Binary value of 0 is 0

also two's complement of 0 in 16 bit is

000000..(16zeros)

16 bit largest positive no:0111111111111111 which is 32767 in decimal

**two's complement of positive number is same as the number

32,768 is the most negative 16 bit decimal number=B(3)

Binary of most negative number:1000000000000000(-32768)=B(5)

2's complement of above number same=B(6)

hence B (7)=-32768

C

base(10) base(16)

2048 = 0800

1023 = 03FF

11281 = 2c11

-10731 = FFFFFFFFFFFFD615

base(2)

0000010000100100 = 424

1110111110101110 = EFAE

base(10)

-8 = FFFFFFFFFFFFFFF8

-4095 = FFFFFFFFFFFFF001

D

9609(base 10)= 10010110001001(base 2) --1 D(1)

1's complement=01101001110110 --2 D(2)

1+2 = 011111111111111( 16383 base(10)) D(3)

twos complement = number itself

16383 = D(4)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote