Question

I need to convert an 8-bit byte of 1's and 0's to a string reading the same thing. This is what I have

string binstring(byte N) { 
string sN(8,'0');
int temp;
for (int i = 0; i < 8; i++){
temp = (N >> i);
if ((temp%2) == '0') {sN[i] = 0;}
else {sN[i] = 1;}
}
return sN + '0';
}

My problem is the conversion is not happening. Nothing is being outputted.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top