I know this is a common problem, and I cannot figure out why I am having so much trouble. I am trying to convert a line from an IDL code to c++
IDL:
for i = 0,7 do begin
b = ishfy(b,1)
print,b
endfor
My C++ code:
for(int i = 0; i < 7; i++)
{
b = b << 1;
cout << b;
}
My initial b is 255, and I expect to receive 254, 252, ect. Instead my first bit shift returns 510. I assume my problem is not converting b to a binary form before shifting. Is this correct? And if so how do I fix it?
Thanks in advance!