Fixed Point macros


Defines

#define FIXED_DIV(Number, Denom)
 Divide two fixed point 1.19.12 values.
#define FIXED_FROMFLOAT(Value)
 Convert a float value into fixed point 1.19.12 format.
#define FIXED_FROMINT(Value)
 Convert an integer into fixed point 1.19.12 format.
#define FIXED_MUL(A, B)
 Multiply two fixed point 1.19.12 values.
#define FIXED_ONE
 1 in fixed point 1.19.12
#define FIXED_PI
 PI in fixed point 1.19.12
#define FIXED_TOFLOAT(Value)
 Convert a float value into a fixed point 1.19.12.
#define FIXED_TOINT(Value)
 Convert a fixed point 1.19.12 value into an integer.
#define FIXED_TRUNC(_Value)
 Truncate a fixed point 1.19.12 value.

Detailed Description

HEL Library provides service macros to convert integer and floating point numbers into 1.19.12 fixed point format and vica versa.

The following macros should be used when dealing with 1.19.12 fixed point numbers. Addition and Substraction work the same way as with integers and don't need extra macros therefore.

The variable type to work with 1.19.12 fixed point numbers is a 32bit integer. HEL Library exclusively uses the sfp32 datatype for fixed point numbers.

For some fixed point example code please refer to "hel/demos/pad2".


Define Documentation

#define FIXED_DIV ( Number,
Denom   ) 

Divide two fixed point 1.19.12 values.

The FIXED_DIV divides the two fixed point 1.19.12 values specified by Number and Denom.

Note:
This macro uses the BIOS divide function. Because of the function call, you cannot use it as data initializer.

#define FIXED_FROMFLOAT ( Value   ) 

Convert a float value into fixed point 1.19.12 format.

Note:
This macro produces slower code than FIXED_FROMINT

#define FIXED_FROMINT ( Value   ) 

Convert an integer into fixed point 1.19.12 format.

The FIXED_FROMINT macro generates a 1.19.12 fixed point number from the number specified by Value.

See also:
FIXED_TOINT

#define FIXED_MUL ( A,
 ) 

Multiply two fixed point 1.19.12 values.

The FIXED_MUL macro multiplies two fixed point 1.19.12 numbers.

#define FIXED_ONE

1 in fixed point 1.19.12

The FIXED_ONE define represents 1 (One) in fixed point 1.19.12 format.

#define FIXED_PI

PI in fixed point 1.19.12

The FIXED_PI define represents PI (3.14159) in fixed point 1.19.12 format.

#define FIXED_TOFLOAT ( Value   ) 

Convert a float value into a fixed point 1.19.12.

The FIXED_TOFLOAT macro generates a float value from the fixed point 1.19.12 number specified by Value.

Note:
This macro should not be used in production code, since floating point computations are very expensive on the GBA.

#define FIXED_TOINT ( Value   ) 

Convert a fixed point 1.19.12 value into an integer.

The FIXED_TOINT macro generates an integer from the fixed point 1.19.12 number specified by Value.

See also:
FIXED_FROMINT

#define FIXED_TRUNC ( _Value   ) 

Truncate a fixed point 1.19.12 value.

The FIXED_TRUNC macro generates the number specified by Value without fraction part. 99.8 becomes 99 and -99.2 becomes -100.


Generated on Sat Aug 12 13:54:08 2006 for HEL 2 Library by  doxygen 1.4.7