How does one construct a mask for the MS bit?

Stew Rubenstein stew at harvard.ARPA
Sun Mar 10 22:35:10 AEST 1985


> seems that this should work:
> 
> #define MSB(a)		(1<<((sizeof a) * 8 - 1))
> 
> for most unix machines.
> -- 
> John Bass
> DMS Design (System Performance and Arch Consultants)
> {dual,fortune,idi,hpda}!dmsd!bass     (408) 996-0557

Is it portable to assume 8 bit bytes?  Answer:  no, but since there is no
bitsizeof operator, sometimes we must.  There are unix machines which do
not use 8 bit bytes (the BBN C-30 and C-70 come to mind, maybe also some
honeywell machines).  There is also the PDP-10 which, to the best of my
knowledge, does not run unix, but does have C.
-- 
-----------------------
Stew Rubenstein     UUCP: ihnp4!harvard!stew
Harvard Chemistry   ARPA: stew at harvard



More information about the Comp.lang.c mailing list