How does one construct a mask for the MS bit?

Daemon dae at psuvax1.UUCP
Mon Mar 11 11:46:21 AEST 1985


The below is at least a stab in the right direction;
our cpp is the "old" 4.2 one--the one without the -M
option.
-----------------------cut here for msb.c------------------------------
#define msb(x) (1 << (8 * sizeof(x)) - 1)

main()
{
	int i = msb(int);
	short s = msb(short);
	char c = msb(char);

	printf("Int:  %d\n", i);
	printf("Short:  %d\n", s);
	printf("Char:  %d\n", c);
}
--------------------------end msb.c-----------------------------------
-- 
 \ / \/ From the furnace of Daemon ( ...{psuvax1,gondor,shire}!dae )
  \  / +1 814 237 1901 "I will have no covenants but proximities"  [Emerson]
   \/
                         Don't get mad.  Get even.



More information about the Comp.lang.c mailing list