0

What does this particular code mean?

byte portData;

 for (var i = 1; i < InstantDiCtrl.Features.PortCount; ++i)
 {
    for (var j = 0; j < 8; ++j)
    {
        Str1[j] = (portData >> j) & 0x1;
    }
 }

I am confused on this part

Str1[j] = (portData >> j) & 0x1;
Ibanez1408
  • 4,550
  • 10
  • 59
  • 110
  • 1
    `Str1` - is an array; `>>` is a bitwise shift operator; `&` is a logical AND. What exactly is confusing you? Have you tried to move with a debugger through this code and understand what is it doing? – JleruOHeP Mar 08 '19 at 04:31
  • Also: https://stackoverflow.com/q/141525/1300049 – JleruOHeP Mar 08 '19 at 04:34
  • The code just shifts bits out and compares them with one, in essence turning a byte into a bit array (binary) – TheGeneral Mar 08 '19 at 04:43

0 Answers0