Re: "Shifting" floating point numbers
- From: Eric Sosman <Eric.Sosman@xxxxxxx>
- Date: Tue, 21 Mar 2006 16:02:20 -0500
Jordan Abel wrote On 03/21/06 15:51,:
On 2006-03-21, woessner@xxxxxxxxx <woessner@xxxxxxxxx> wrote:
Does anyone know of a fast way to multiply floating point numbers by
powers of two? Conceptually, all you need to do is add to the
mantissa. But can I write C code (or x86 assembly) to accomplish this
without a full-blown multiply?
For example, I'd like to be able to do the following very quickly:
double x;
double y;
x = 42.13;
y = (1 << 9) * x;
Thanks in advance,
Bill
y = scalbn(x,9);
ITYM:
#if FLT_RADIX == 2
y = scalbn(x, 9);
#else
y = ???;
#endif
I've already posted a candidate for "???", one that
eliminates the dependency on C99 and perhaps even
obviates the preprocessor gunk ...
--
Eric.Sosman@xxxxxxx
.
- References:
- "Shifting" floating point numbers
- From: woessner
- Re: "Shifting" floating point numbers
- From: Jordan Abel
- "Shifting" floating point numbers
- Prev by Date: Re: Array setup Question
- Next by Date: Re: Strcpy
- Previous by thread: Re: "Shifting" floating point numbers
- Next by thread: Re: "Shifting" floating point numbers
- Index(es):
Relevant Pages
|