Erros while bitshifting an integer

Hey there fellow programmers,

I'm trying to build a library where I need to bit-shift an integer to get all the bits into a boolean in order.

I jused this line of code to do it:

bool dataForPin = pinRowData >> i;

Where pinRowData is an unsigned integer in an array of 19 and i is an increment with the byte
datatype. However, while compiling I get the following error:

invalid operands of types 'unsigned int [19]' and 'byte {aka unsigned char}' to binary 'operator>>'

I checked out the arduino documentation and it says I can use the bit operators on bytes, integers, and longs. A google search also lead to nothing. Not for the arduino language or C++. Does anyone have an idea about where I should start looking?

You haven't shown us your datatypes.
Guessing that pinRowData is an array.
Did you mean to isolate an element of that array with an index, and shift that?


"all the bits into a boolean" is a logical contradiction. The bool type has only two values, true and false. It is not defined for bitwise operations or bitwise addressing. You should use 'unsigned char' or, in Arduino world, 'byte'.

unsigned int pinRowData[19];
bool dataForPin = pinRowData >> i;

You can't shift an array, only a single integer.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.