Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!brl-tgr!tgr!cottrell@nbs-vms.ARPA From: cottrell@nbs-vms.ARPA Newsgroups: net.lang.c Subject: How does one construct a mask for the MS bit? Message-ID: <8822@brl-tgr.ARPA> Date: Fri, 1-Mar-85 11:50:35 EST Article-I.D.: brl-tgr.8822 Posted: Fri Mar 1 11:50:35 1985 Date-Received: Sun, 3-Mar-85 03:43:50 EST Sender: news@brl-tgr.ARPA Lines: 15 /* > This would require generation of a mask for the most significant bit int msbit() { register int msb = 1; while ((msb <<= 1) > 0); return(msb); } I am assuming that the msb is used as the sign bit. If that's not portable, then shift until msb is zero, counting the shifts. Then return(1 << --count). (I am also assuming an int is more than one bit :-) jim */