fix.cpp File Reference

32-bit fixed-point maths routines More...

#include "common.h"
#include "fix.h"
Include dependency graph for fix.cpp:

Go to the source code of this file.


#define FIX_USE_64BIT_MUL


static int Interpolate (const int *table, int value, int shift)

Detailed Description

32-bit fixed-point maths routines

Definition in file fix.cpp.

Define Documentation

#define FIX_USE_64BIT_MUL

If this macro is defined, the implementation of the multiply methods will use 64bit arithametic. This produces much more efficient code on some architecture/compiler combinations, like ARM+GCC.

Definition at line 41 of file fix.cpp.


If this macro is defined, the implementation of the Fix::Div will use an unrolled loop. This may produce faster code.

Definition at line 47 of file fix.cpp.

Function Documentation

static int Interpolate ( const int *  table,
int  value,
int  shift 
) [static]

Helper function for interpolatating lookup tables used by transcendental functions.

If the lookup table represents the function f(x) over the range 0 to N<<shift, then it must contain entries for: { f(-1<<shift), f(0), f(1<<shift), f(2<<shift), ... f((N-1)<<shift)), f(N<<shift), f((N+1)<<shift)) }. This function then returns f(value).


  • Each entry in the table must have a value greater than the preceding one.
  • This function produces undefined results due to arithmatic overflow when the difference between any adjacent table entries is close to the maximum value of an int shifted right by shift. (The exact conditions which cause overflow are more complex than this, therefore it is advised that any table is tested for correctness using all posible values of value.)
table The lookup table.
value The value to lookup in table.
shift The number of least significant bits in value which are discarded when indexing into table.
The interpolated result of looking up value in table.

Definition at line 74 of file fix.cpp.

Generated by  doxygen 1.6.1