How does one construct a mask for th
Ron Natalie <ron>
ron at brl-tgr.ARPA
Thu Mar 7 03:05:14 AEST 1985
> >> /*
> >> This would require generation of a mask for the most significant bit
> >> */
>
> #define MSB (~(-1>>1))
>
Surprise, this doesn't even work on VAX's and PDP -11's. -1>>1 is still
-1. Be careful when coming up with ideas like these. C has also been
implemented on ones-complement (and subtractive arithmatic) machines.
Right shifting of signed quantities is defined to be machine depenedant
in C.
-Ron
More information about the Comp.lang.c
mailing list