0

(Not sure if I am allow to ask a question like this but will delete if asked) Convert -25 into binary representation using 8 bits and 2's complement format to represent a negative number. So far I got 11001.

I tried to google methods but I am not sure how to do it using the 8 bits way.

This question is not using code, just conversions but from what I did was convert it to binary which was 11001 then I added 3 zero's to make it 8bits (assuming that is correct) 00011001 then I did 1's complement 11100110 and 2's complement by adding 1 which equals 11100111.

I am not sure if that is correct.

user207421
  • 305,947
  • 44
  • 307
  • 483
Carloose
  • 29
  • 1
  • 2
  • 9
  • The type of question is fine, However you need to demonstrate that you've put in some effort and describe the exact issue you're facing. Details are helpful. Can you show the parts of your code that you need help with? – RaGe Apr 24 '15 at 00:04
  • "*this question is not using code,*" Ah! In which case, I'm sorry, it **is** offtopic on this site. Stackoverflow is meant for programming questions. – RaGe Apr 24 '15 at 00:13
  • Decimal-to-Binary conversion is tangentially related to programming. Plus, [similar](http://stackoverflow.com/questions/1049722/what-is-2s-complement) [questions](http://stackoverflow.com/questions/13735443/twos-complement) have been asked before without issue. – grill Apr 24 '15 at 00:27
  • 2's *complement.* Not 'compliment'. – user207421 Apr 09 '17 at 10:23

2 Answers2

5

Two's complement is probably one of the more straightforward operations on binary numbers. In short, you'll want to take the following actions to convert a decimal number into two's complement form:

  1. Write down the binary representation of the positive version of your number. In this case, 25 should be represented as: 00011001
  2. Next, flip all the digits: 11100110
  3. Add one: 11100111
  4. Sit back, grab a drink, and bask in the glory of the newly-created two's complement representation of a decimal number.

Source

grill
  • 1,160
  • 1
  • 11
  • 24
0

1.assume the negative sign and get the binary of the positive integer.adopt 8bit notation 25--00011001 2.get the two's complement. 11100111 + 1 =11111000 3.relax and enjoy the two's complement