home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / programm / 2302 < prev    next >
Encoding:
Text File  |  1992-08-13  |  1.4 KB  |  31 lines

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