From: Terje Mathisen <terje.mathisen@hda.hydro.com>
Subject: Re: Can POWER4, 5 etc continue where Alpha was stopped?
Date: Fri, 31 Aug 2001 12:09:07 +0200 [thread overview]
Message-ID: <3B8F6243.F26ABBB0@hda.hydro.com> (raw)
In-Reply-To: name99-2908011445220001@handma2.apple.com
Maynard Handley wrote:
>
> In article <3B8C8AC4.59ED22CB@hda.hydro.com>, Terje Mathisen
> <terje.mathisen@hda.hydro.com> wrote:
> > Optimized code can indeed make use of a fast way to determine if a
> > number is a power of two, I've used that particular idiom several times.
>
> I think the main thing is to ensure that things like this are wrapped in a
> macro rather than directly in the code. Not only does that make the code
> much easier to read but it allows one to restructure the macro if
> appropriate to a new platform. (Unlikely for this example, but can be
> likely in other situations eg when one moves from big to little-endian.)
Absolutely!
In my own code I've tried to use this kind of stuff inside a macro, i.e.
if (ispowerof2(n)) {
...
}
This also makes it much easier to replace the macro with a function,
something that would be needed if I later needed to switch to a
different (fp?) number format.
BTW, the same test on a single prec fp number is even easier, since it
just needs to verify that the fractional part of the mantissa is zero:
#define float_ispowerof2(n) (((*(t_uint32 *) &n) & 0x07ffffff) == 0)
Terje
--
- <Terje.Mathisen@hda.hydro.com>
Using self-discipline, see http://www.eiffel.com/discipline
"almost all programming can be viewed as an exercise in caching"
next prev parent reply other threads:[~2001-08-31 10:09 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-26 17:14 Can POWER4, 5 etc continue where Alpha was stopped? Nova
2001-08-26 22:30 ` del cecchi
2001-08-28 17:39 ` Niels Jørgen Kruse
2001-08-28 18:47 ` Christer Palm
2001-08-28 20:00 ` Del Cecchi
2001-08-27 1:38 ` Robert Deininger
2001-08-27 17:12 ` Richard Tomkins
2001-08-28 19:02 ` McCalpin
2001-08-28 10:14 ` Bruce Hoult
2001-08-29 0:03 ` McCalpin
2001-08-28 15:27 ` Bruce Hoult
2001-08-29 6:25 ` Terje Mathisen
2001-08-29 11:48 ` George Coulouris
2001-08-29 17:30 ` Terje Mathisen
2001-08-29 19:32 ` Terje Mathisen
2001-08-29 21:45 ` Maynard Handley
2001-08-31 10:09 ` Terje Mathisen [this message]
2001-08-31 16:09 ` Serguei Patchkovskii
2001-09-01 19:51 ` Terje Mathisen
2001-08-28 20:38 ` Andi Kleen
2001-08-28 10:16 ` Bruce Hoult
2001-08-28 20:51 ` Nick Maclaren
2001-08-28 23:04 ` Andi Kleen
2001-08-29 7:59 ` Nick Maclaren
2001-08-30 20:18 ` Wow
2001-08-31 7:47 ` Terry C. Shannon
2001-08-31 9:09 ` Ketil Z Malde
2001-08-31 12:52 ` Terry C. Shannon
2001-08-31 13:14 ` McCalpin
2001-09-03 12:23 ` Alexis Cousein
2001-09-05 1:27 ` del cecchi
2001-09-05 2:07 ` Chris Morgan
2001-09-05 18:13 ` Del Cecchi
2001-09-05 18:57 ` Larry Kilgallen
2001-09-05 12:49 ` Sander Vesik
2001-09-05 14:17 ` McCalpin
2001-09-05 14:59 ` Michael Kraemer
2001-09-05 16:32 ` Pentyern
2001-09-06 0:32 ` del cecchi
2001-09-05 18:08 ` Terry C. Shannon
2001-09-06 13:42 ` Stefaan A Eeckels
2001-09-06 15:08 ` Alexis Cousein
2001-09-06 16:40 ` Mark Smotherman
2001-09-06 21:57 ` Stefaan A Eeckels
2001-09-07 16:22 ` Peter da Silva
2001-08-31 12:20 ` Nick Maclaren
2001-09-03 15:07 ` bad bob
2001-08-28 21:16 ` Greg Lindahl
2001-08-29 0:06 ` McCalpin
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox