How does one construct a mask for th

ed at ISM780.UUCP ed at ISM780.UUCP
Thu Mar 7 15:23:49 AEST 1985


>    #define MSB (~(-1>>1))
>
>    Steve Ludlum, decvax!yale-co!ima!stevel, {cca!ihnp4!cbosgd}!ima!stevel

I think you need

#define MSB (~((unsigned)-1>>1))

Right shift is only guaranteed to fill by zeroes if the left operand is
unsigned.

Ed Lycklama
decvax!cca!ima!ism780!ed



More information about the Comp.lang.c mailing list