### signed

#### converting signed 255 into 8-bit twos complement

I need to convert a signed decimal number (255) into 8-bit two's complement for a HW problem. My problem is that I'm not sure how to make a number like 255 positive with 8-bits, because I believe the range is -128 to 127, correct? If 01111111 is 127, then how can I get 255 into binary with just 8 bits. I think I just don't understand if "signed" is only referring to the decimal number or if it also refers to the binary number.

A signed value of 255 would have to - at minimum - be represented in 9 bits. 0...11111111 = +225 Given an 8 bit representation, you are correct, we can represent only up to +127/-128. Were we to cast signed 255 to an 8 bit field, we'd lose the semantic meaning of the first bit, leaving us with 11111111 representing -1 (though potentially -0, depending on our implementation). Attempting to take the two's complement of this value would yield: 11111111 00000000 (flip bits) 00000001 (add one) = 1 (integer value) Like I said in the comment, this looks to me like a question I would have been asked to query my understanding of that signed bit and it consuming a bit of numeric representation, which you seem to have figured out already.

I'm definitely not an expert in this sort of stuff but are you sure you have the question correct? Surely signed refers to the binary number only?

In 8bit stands for byte and it is unsigned and and the range that covers is from 0 to 255 so 255 decimal should be 11111111 in 8bit Signed means that negative number are also allowed if you have to cover the range from -255 to 255 you can put the negative number in one byte and the positves in the other byte

### Related Links

anyone know a signed kext will expire(not working) after Apple Developer membership expires?

converting signed 255 into 8-bit twos complement

Converting from 8 bit to 16 bit

Exception connecting to SQL Server CE 4.0