I need java code that takes a 32bit long binary number and p
I need java code that takes a 32-bit long binary number and performs the two\'s complement on it. This should result in the negative of the binary number.
Solution
Here is the method which will do the needful for you:
public static void twosComplementOfBinary(char[] binary)
 {
 int i;
 for(i = 32; i >= 0; i--)
 {
 if(binary[i] == \'1\')
 break;
 }
 for(; i >= 0; i--)
 if(binary[i] == \'0\')
 binary[i] = \'1\';
 else
 binary[i] = \'0\';
 }

