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

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -