public class BinaryMutiply {
public static void main(String[] args) {
System.out.println(binaryMutiply(120,130));
}
public static int binaryMutiply(int a,int b){
int sum = 0;
for (int x = 1; x <= 32; x++) {
if ((b & Integer.MIN_VALUE) == Integer.MIN_VALUE) {
sum = (sum + a);
} else {
}
if (x != 32) {
sum = (sum << 1);
}
b <<= 1;
}
return sum;
}
}
|
|