|
Author Topic:   Fixed Point Performance
Oiler
Member
posted October 11, 1999 01:14 PM            
I have never used fixed-point calculations before and am curious about how much faster my implementation will be after I put them in. Does anyone have some code or a class that will show me how to use them as I know very little about them?

IP:

assen
Member
posted October 11, 1999 03:16 PM            
Well, don't get your hopes too high floating point math is cheap today compared to memory accesses, and to achieve a real speedup with fixed point you'll probably need to hand-code in assembler some critical sections of your code.

IP:

Oiler
Member
posted October 11, 1999 03:21 PM            
Your the second person I've heard that from today. Well anyway I found a few utility functions for others that may want to experiment:

typedef long fixed; // Our new fixed point type.

#define itofx(x) ((x) << 8) // Integer to fixed point
#define ftofx(x) ((x) * 256) // Float to fixed point
#define dtofx(x) ((x) * 256) // Double to fixed point
#define fxtoi(x) ((x) >> 8) // Fixed point to integer
#define fxtof(x) ((float) (x) / 256) // Fixed point to float
#define fxtod(x) ((double)(x) / 256) // Fixed point to double
#define Mulfx(x,y) (((y) * (x)) >> 8) // Multiply a fixed by a fixed
#define Divfx(x,y) ((y << 8) / (x)) // Divide a fixed by a fixed
#define Printfx(x) printf("%ld.%ld", x >> 8, 100 * (unsigned long) ((x) & 0x00ff) >> 8)
// Print fixed point.
#define NDPrintfx(x) printf("%ld", x >> 8)
// Print fixed point without a decimal point.

IP:

Sam K
Member
posted February 18, 2000 08:25 PM            
Maybe I could have put my previous post in here rather than in "Code Optimizations"
seems more relevant.
(See my "Code optimizations" post for details)

regards,

sam

IP: