title: How to convert a negative integer into two's complement binary form? (Java)
body: <p>I need to convert numbers, positive and negative, into binary format - so, 2 into "00000010", and -2 into "11111110", for example. I don't need more than 12 bits or so, so if the string is longer than that I can just trim off the leading sign bits. It seems like <code>Integer.toBinaryString()</code> will do positive numbers, but is there one that can do negatives?</p>