The value of the two-byte two’s complement value 0xFF72 is?

The value of the two-byte two’s complement value 0xFF72 is:

A. -28
B. -84
C. -128
D. -142

Hey guys I'm having trouble with this question. I want to be able to solve this but I was hoping if there was a source or if someone could tell me step by step on how to solve this.

Thank you.
There are 2 common ways to negate a signed number in 2's compliment.

Technique A) Invert all bits, then add 1

Technique B) Subtract the number from 1+ the maximum possible. In this case, since it's a 2-byte number, 1 + the maximum is 0x10000. So 0x10000 - 0xFF72


Once you do that, you have the negated number, which you can convert to decimal.
Last edited on
Assuming you're in a 2's complement environment...

1
2
3
4
5
6
7
8
#include <iostream>
#include <cstdint>

int main()
{
    std::int16_t value = 0xFF72 ;
    std::cout << value << '\n' ;
}


or that.

=P
Hey guys thank you so much. both of you guys gave great replies.

I do have another question..

A 4 byte float has the value: 0x00000000. Its value as a floating point number is:

for this question I am now using a 4 byte float and trying to convert it to a floating point number. Could you guys give me the steps for this?

Thanks!
Topic archived. No new replies allowed.