What is bitwise Xor
How will this code convert decimal to binary.
public void decToBinary(int n)
{
// Size of an integer is assumed to be 32 bits
for (int i = 31; i >= 0; i--) {
int k = n >> i;
if ((k & 1) > 0)
System.out.print("1");
else
System.out.print("0");
}
now below given code does the same
public String inBinary(int num) {
if (num == 0) return "0";
String s = "";
while (num > 0) {
s = (num % 2) + s;
num = num / 2;
}
return s;
}