<<< Decimal to Binary Conversion | Index | Negation >>> |
Conversion to 2's complement integers can be summarized by the following steps:
If number is even, the rightmost bit is zero.
If number is odd, the rightmost bit is one.
Subtract zero or one.
Divide both sides by 2.
Repeat.
The series of iterations produce a sequence of bit patterns from right to left.
If original decimal number is negative,
Follow steps 1-5 from above.
Append leading zero bit to the result.
Convert the result to 2's complement representation by taking complement and adding one.
More examples here:
<<< Decimal to Binary Conversion | Index | Negation >>> |