home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.programming
- Path: sparky!uunet!usc!venice!reuter
- From: reuter@venice.sedd.trw.com (Joseph Reuter)
- Subject: Re: finding 1st one in integer
- Message-ID: <1992Aug14.153612.13724@venice.sedd.trw.com>
- Organization: TRW Systems Engineering & Development Division, Carson, CA
- References: <1992Aug9.072022.9391@linus.mitre.org> <H.b_Q8qXezVYo@jonh.wimsey.bc.ca> <Bsx578.CzD@metropolis.com>
- Date: Fri, 14 Aug 1992 15:36:12 GMT
- Lines: 22
-
- In article <Bsx578.CzD@metropolis.com> robert@metropolis.com (Robert Munyer) writes:
- >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.
- >
-
- On the CDC6600, this was accomplished using the floating-point unit, provided
- the number in question was less than 2**48. The number was converted to
- unnormalized floating-point by ORing it with 0x200000000000000 and then
- normalizing. The normalize instruction returned the number of left shifts
- required, but the count could also be obtained by examining the exponent
- part of the normalized floating-point number.
-
- I don't know enough about the IEEE floating-point system to know if a
- similar trick would work there. If it does, this technique, while not
- perfectly portable, might be widely applicable.
-
- --
- Joseph A. Reuter, Wizard-in-Training
- Speaking for myself from reuter@venice.sedd.trw.com
- "Olorin I was in the West that is forgotten." -- J.R.R. Tolkien
- "You can't win, you can't break even, and you can't quit the game."
-