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: <8849@brl-tgr.ARPA> Date: Fri, 1-Mar-85 18:53:53 EST Article-I.D.: brl-tgr.8849 Posted: Fri Mar 1 18:53:53 1985 Date-Received: Sun, 3-Mar-85 03:49:39 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 */