C - Combine las three bits of a byte with a byte -
C - Combine las three bits of a byte with a byte -
lets have byte in binary: f= 01010111, i'll this: f<<3 im expecting: 10111000, @ point im going have byte, lets other 1 10111001 , want attach them result 1011110111001. basiclly, want lastly 3 bits first byte swap sec byte.
i have no thought how can this, can help me please?
thanks!
how this?
uint8_t f = 0x57; // 0b01010111 f <<= 3; // 10111000 uint8_t g = 0xb9; // 0b10111001 uint16_t out = (f << 5) | g; printf("0x%04x\n", out); > 0x17b9 // 0b1011110111001
i don't understand intermediate << 3
i'm assuming it's part of application.
c byte bit
Comments
Post a Comment