user
What is the conversion of -658 from decimal to binary base?
alphonsio

-658 in binary (2's complement on 16 bits) is: 1111 1101 0110 1110

(658)10=(1111 1101 0110 1110)2(-658)_{10}=(1111~1101~0110~1110)_2


To convert the number -658 from decimal to binary, we first convert the positive number 658 to binary, then encode the negative sign (2's complement).

1. absolute value conversion (658)

Let's divide 658658 by 22 and note the remainder at each step:

  • 658÷2=329658 \div 2 = 329, remainder 0
  • 329÷2=164329 \div 2 = 164, remainder 1
  • 164÷2=82164 \div 2 = 82, remainder 0
  • 82÷2=4182 \div 2 = 41, remainder 0
  • 41÷2=2041 \div 2 = 20, remainder 1
  • 20÷2=1020 \div 2 = 10, remainder 0
  • 10÷2=510 \div 2 = 5, remainder 0
  • 5÷2=25 \div 2 = 2, remainder 1
  • 2÷2=12 \div 2 = 1, remainder 0
  • 1÷2=01 \div 2 = 0, remainder 1

Reading the remainders from bottom to top, the binary conversion of 658658 is :

(658)10=(1010010010)2(-658)_ {10} = (1010010010)_2

2. Negative sign

The negative sign is represented by the 2's complement. Invert each bit and add 1 to the result:

Step 1: invert the bits of 1440658 (1010010010)

  • Inverted: 0101101101

Step 2 : Add 1

  • 0101101101 + 1 = 0101101110

Step 3 : Complete with 1s

  • Add 1's to obtain a 16-bit representation: 1111 1101 0110 1110

On 16 bits, this gives :

(658)10=(1111 1101 0110 1110)2(-658)_{10}=(1111~1101~0110~1110)_2