The following code calculates the parity of number.
The question is what happens in the line count^=(number&1). The bitwise AND operation will result in a long. The a bitwise OR is performed between a short (count) and a long (number&1), which should result in a long. Why can the result still be saved in a short valiable (count)?
long number=17;
public short parityCalc() {
short count=0;
for(int c=0;c<64;c++){
count^=(number&1);
number>>>=1;
}
return count;
}