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

-523 in binary (2's complement on 16 bits) is: 1111 1101 1111 0101

(523)10=(1111 1101 1111 0101)2(-523)_{10}=(1111~1101~1111~0101)_2


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

1. absolute value conversion (523)

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

  • 523÷2=261523 \div 2 = 261, remainder 1
  • 261÷2=130261 \div 2 = 130, remainder 1
  • 130÷2=65130 \div 2 = 65, remainder 0
  • 65÷2=3265 \div 2 = 32, remainder 1
  • 32÷2=1632 \div 2 = 16, remainder 0
  • 16÷2=816 \div 2 = 8, remainder 0
  • 8÷2=48 \div 2 = 4, remainder 0
  • 4÷2=24 \div 2 = 2, remainder 0
  • 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 523523 is :

(523)10=(1000001011)2(-523)_ {10} = (1000001011)_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 523 (1000001011)

  • Inverted: 0111110100

Step 2 : Add 1

  • 0111110100 + 1 = 0111110101

Step 3 : Complete with 1s

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

On 16 bits, this gives :

(523)10=(1111 1101 1111 0101)2(-523)_{10}=(1111~1101~1111~0101)_2