N3DFLOAT Struct Reference

Describes a signed 32bit fixed point type. More...

#include <n3dtypes.h>


Detailed Description

Describes a signed 32bit fixed point type.

The Nintendo DS hardware does not have a Floating Point Unit, thus N3D provides the N3DFLOAT type, which simulates floats by using fixed point arithmetic.

The N3DFLOAT is implemented as a struct of a size of 32bit, therefor fits into one register and does not produce overhead, but is typesafe! If you pass a single N3DFLOAT as parameter, don't pass it as reference or pointer, as this generates extra code. Pass it by value instead. Some operators are overloaded to work with the N3DFLOAT as with other types. All N3DFLOAT operations are inlined in _RELEASE mode and don't consume function call overhead therefor.

The N3DFLOAT format is 1bit sign, 19bit decimal part, 12bit fraction.

Example:

    N3DFLOAT a;
    N3DFLOAT b(2.0);

    a = N3DFLOAT(22) * b + N3DFLOAT(10);

Remarks:
As with regular signed values, the most significant bit is the sign flag. Therefor, if a N3DFLOAT holds a very big positive value and overwrites the sign flag bit, it becomes a negative value. This problem can be a real pain and produce endless of debugging hours, always be aware of it!

Generated on Wed Aug 29 19:48:05 2007 for N3D by  doxygen 1.5.3