Re: "Shifting" floating point numbers
- From: Skarmander <invalid@xxxxxxxxxxxxxx>
- Date: Tue, 21 Mar 2006 20:22:20 +0100
woessner@xxxxxxxxx wrote:
Does anyone know of a fast way to multiply floating point numbers byMy advice: don't bother. The chance that you'll beat the combination of FPU and compiler is small, and a trick like this tends to break down when you least expect it.
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, if you want to do this the right way, you have to deal with the infinities, denormalized numbers, NaNs and last but not least, zero. But of course you can't, since that would make your code far too slow.
For example, I'd like to be able to do the following very quickly:Verify that you really need to do this faster than you're doing it now first. Then see if there's some way to avoid doing the multiplication altogether (at least in tight loops) by changing the way you handle your data. Finally, if all these options are exhausted, you'd best go with x86 assembler and read up on the format of double precision numbers. Try comp.lang.asm.x86. When you're at this point, C (even nonportable C) is unlikely to help you enough.
double x;
double y;
x = 42.13;
y = (1 << 9) * x;
S.
.
- References:
- "Shifting" floating point numbers
- From: woessner
- "Shifting" floating point numbers
- Prev by Date: Re: Array setup Question
- Next by Date: Re: MEmory Addres of DOS screen
- Previous by thread: Re: "Shifting" floating point numbers
- Next by thread: Re: "Shifting" floating point numbers
- Index(es):
Relevant Pages
|