home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.programming
- Path: sparky!uunet!nntp1.radiomail.net!fernwood!metrop!robert
- From: robert@metropolis.com (Robert Munyer)
- Subject: Re: finding 1st one in integer
- Message-ID: <Bsx578.CzD@metropolis.com>
- Organization: Metropolis Software, Inc.
- References: <BsM2z9.1KA@metropolis.com> <1992Aug9.072022.9391@linus.mitre.org> <H.b_Q8qXezVYo@jonh.wimsey.bc.ca>
- Date: Thu, 13 Aug 1992 10:59:29 GMT
- Lines: 20
-
- In article <H.b_Q8qXezVYo@jonh.wimsey.bc.ca> jhenders@jonh.wimsey.bc.ca writes:
-
- > 68k chips support a rotate right or left which would allow a rotate,
- > followed by a test of the lsb. Do any other chips have rotate?
- > Of course, this wouldn't be portable, as it would have to be done in
- > assembly.
-
- Yes, many other chips have rotate. In fact, I can't think of one that doesn't.
- And it DOESN'T have to be done in assembly; C has the << and >> operators,
- which compile directly into bit-shift instructions (not exactly the same thing
- as rotate, but close enough for this particular situation).
-
- But the point of this discussion is that we're looking for ways to find the
- most significant "one" bit (i.e., count the number of leading 0's) WITHOUT
- having to go through a loop 31 times.
-
- ______________________________________________________________________
- Robert Munyer | "I may be synthetic, but I'm not stupid."
- robert@metropolis.com | -- Bishop, _Aliens_
-
-