Main Page | Modules | Data Structures | File List | Data Fields | Globals

fixedpoint.h File Reference

16.16 fixed point math functions. More...

#include <68332/types.h>

Go to the source code of this file.

Defines

#define INT_TO_FIXED(x)   ((x) << 16)
#define DOUBLE_TO_FIXED(x)   ((long)((x) * 65536.0 + 0.5))
#define FIXED_TO_INT(x)   ((x) >> 16)
#define FIXED_TO_DOUBLE(x)   (((double)(x)) / 65536.0)
#define ROUND_FIXED_TO_INT(x)   (((x) + 0x8000) >> 16)
#define FIXED_ONE   INT_TO_FIXED(1)
#define FIXED_PIDIV4   51472L
#define FIXED_PIDIV2   102944L
#define FIXED_PI   205887L
#define FIXED_2PI   411775L
#define FIXED_E   178144L
#define FIXED_LN2   45426L
#define FIXED_SQRT2   92682L
#define FLOAT_PI   3.141592654

Functions

int32 fpmul (int32 x, int32 y)
int32 fpdiv (int32 x, int32 y)
int32 fpsqrt (int32 x)
int32 fpsin (int32 x)
int32 fpcos (int32 x)
int32 fptan (int32 x)
int32 fpatan (int32 x)
int32 fpexp (int32 x)
int32 fpln (int32 x)


Detailed Description

This file contains the global function prototypes, macros, and numerical constants for the libfixed fixed point math library.

To use the functions defined in this file, include <68332/fixedpoint.h> and link libfixed.a.


Define Documentation

#define INT_TO_FIXED  )     ((x) << 16)
 

#define DOUBLE_TO_FIXED  )     ((long)((x) * 65536.0 + 0.5))
 

#define FIXED_TO_INT  )     ((x) >> 16)
 

#define FIXED_TO_DOUBLE  )     (((double)(x)) / 65536.0)
 

#define ROUND_FIXED_TO_INT  )     (((x) + 0x8000) >> 16)
 

#define FIXED_ONE   INT_TO_FIXED(1)
 

#define FIXED_PIDIV4   51472L
 

#define FIXED_PIDIV2   102944L
 

#define FIXED_PI   205887L
 

#define FIXED_2PI   411775L
 

#define FIXED_E   178144L
 

#define FIXED_LN2   45426L
 

#define FIXED_SQRT2   92682L
 

#define FLOAT_PI   3.141592654
 


Function Documentation

int32 fpmul int32  x,
int32  y
 

Multiplies two 16.16 fixed point numbers together, returning a 16.16 fixed point product. Note: No checking for overflow is performed.

Parameters:
x The first multiplicand.
y The second multiplicand.
Returns:
The product.

int32 fpdiv int32  x,
int32  y
 

Divides a 16.16 fixed point dividend by a 16.16 fixed point divisor, returning a 16.16 fixed point quotient. Note: No checking for underflow is performed.

Parameters:
x The dividend.
y The divisor.
Returns:
The quotient.

int32 fpsqrt int32  x  ) 
 

Calculates the square root of a 16.16 fixed point number, returning a 16.16 fixed point result. Note: No checking for underflow is performed.

Parameters:
x The input value.
Returns:
The square root.

int32 fpsin int32  x  ) 
 

Calculates the sine of a 16.16 fixed point number, returning a 16.16 fixed point result. Note: The input will be transformed to within the range of -FIXED_PI to +FIXED_PI.

Parameters:
x The input value in radians.
Returns:
The sine of x.

int32 fpcos int32  x  ) 
 

Calculates the cosine of a 16.16 fixed point number, returning a 16.16 fixed point result. Note: The input will be transformed to within the range of -FIXED_PI to +FIXED_PI.

Parameters:
x The input value in radians.
Returns:
The cosine of x.

int32 fptan int32  x  ) 
 

Calculates the tangent of a 16.16 fixed point number, returning a 16.16 fixed point result. Note: The input will be transformed to within the range of -FIXED_PI to +FIXED_PI. Note: The return value will be in the range of -32768.0 to 32767.999984741

Parameters:
x The input value in radians.
Returns:
The tangent of x.

int32 fpatan int32  x  ) 
 

Calculates the arctangent of a 16.16 fixed point number, returning a 16.16 fixed point result. Note: The return value will be in the range of -FIXED_PI/2 to FIXED_PI/2

Parameters:
x The input value.
Returns:
The arctangent of x in radians.

int32 fpexp int32  x  ) 
 

Calculates the base e exponential of a 16.16 fixed point number, returning a 16.16 fixed point result. Note: No checking for overflow is performed.

Parameters:
x The input value.
Returns:
The exponential result.

int32 fpln int32  x  ) 
 

Calculates the base e logarithm of a 16.16 fixed point number, returning a 16.16 fixed point result. Note: No checking for underflow is performed.

Parameters:
x The input value.
Returns:
The logarithm result.


Generated on Wed Sep 6 03:02:22 2006 for MotoRobots by doxygen 1.3.6