So lets say we have a function that can take either a positive or a negative integer binary string and count the amount of right shifts it takes to get to get to the leftmost significant bit
I have something like this
int shiftCount(int x){
int count = 0;
int temp = x;
while((temp!=1) || (temp!=-1)){ //if negative int, terminate at first -1
count+=1;
temp=temp>>1;
}
return count;
}
This does not return what I want. It ends up in a never ending loop I assume it is because it is trying to fulfill both conditions. Is there an actual way to easily test for 2 different signed values in a while loop, or will I have to make 2 separate conditional statements, each with their own while loop?