Reputation: 145
I'm having a hard time understanding my issue:
uint8_t nal_type=6;
for(i=7;i!=0;i--){
printf("%d",(nal_type>>i)&0x01U);}
printf("\n");
I would expect the following code to display the binary value from MSB to LSB. But it displays the following:
0000011
Can someone enlighten me ?
Upvotes: 0
Views: 763
Reputation: 213060
It's just a simple mistake in your loop, so you're not seeing the LS bit (bit 0) - make it:
for (i = 7; i >= 0; i--)
{ ^^^^^^
printf("%d", (nal_type >> i) & 0x01U);
}
This will then give the output as:
00000110
which I think is what you are looking for (MSB to LSB).
Upvotes: 2