Hello that I am trying to make a function to tell me how to know if a byte is powered on or not but it must be through a mask depending on the position you send
bool estaEncendido(char byte,int pos) { // byte = byte<<(7-pos) ; //byte = byte>>(pos+1); int mask=1; int result =1; for(pos=0; pos<8; pos++, mask <<=1) { if((byte & mask) !=0) { result = 0; break; } //return byte; } }
In the main should have been as well
System.out.print(estaEncendido(5/*000000101*/,2/*00000100*/));
/*00000101 */
/*00000100 &*/
/*00000100*/This ignition