c - Turn on MSB of 8 bit integers -


how show mask , turn on msb of 8 bit integer? have tried different logical opeartors not getting right answers

if have 8 bit integer turning msb set '1' bit 7.

so mask 0x80 (only bit 7 on).

in order set bit can use bit-wise or |:

#define msb_mask 0x80 // or #define msb_mask (1 << 7)  int x; x = x | msb_mask; // or x |= msb_mask; make shorter 

Comments

Popular posts from this blog

swift - Button on Table View Cell connected to local function -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

c# - ajax - How to receive data both html and json from server? -