back TypeServer QuickTour

Fixed-Point Math

For fast performance TypeServer is tightly optimized using fix-point arithmetic based on integer math.  The TypeServer source code allows you to choose between two fixed-point formats referred to as "F26DOT6" (32-bits, F26.6) and "F12DOT4" (16-bits, F12.4).

The F26DOT6 data type consists of a 26-bit signed mantissa and a positive unsigned 6-bit fraction (32-bits total).  This data type is typically used to define fraction pixel positions for 32- and 64-bit processors.

The F12DOT4 data type consists of a 12-bit signed mantissa and a positive unsigned 4-bit fraction (16-bits total).  This data type is typically used to define fraction pixel positions for 16- and 8-bit processors.

The F26DOT6 and F12DOT4 data types provide fractional accuracy to 1/64th or 1/16th if a unit, respectively.  For example, a pixel position in F26DOT6 format provides fractional accuracy to 1/64th of a pixel.

"FIXDOT" is a special conditional data type equated either to F26DOT6 or F12DOT4 depending if the identifier "FIXDOT26" is defined.  Normally FIXDOT26 is defined 32-bit systems, and is left undefined for 16-bit systems (again, this is a TypeServer source code option that is easily changed).


typedef signed long   F26DOT6; /* F26.6 signed fixed-point, 32-bit */

typedef struct F26POINT_       /* F26.6 coordinate-point structure */
{
    F26DOT6  x;
    F26DOT6  y;
} F26POINT;

typedef signed short  F12DOT4; /* F12.4 signed fixed-point, 16-bit */

typedef struct F12POINT_       /* F12.4 coordinate-point structure */
{
    F12DOT4  x;
    F12DOT4  y;
} F12POINT;

/* FIXDOT conditional data type based on if "FIXDOT26" is defined  */
#ifdef   FIXDOT26 /* (typically for 32-bit systems)  - - - - - - - */
#define FIXDOT    F26DOT6   /* FIXDOT is signed fixed-point F26DOT6*/
#define FIXPOINT  F26POINT  /* F26.6 coordinate-point structure    */
#define IntToFix(intValue)  (FIXDOT)( (intValue) << 6 )

#else  /*FIXDOT12  * (typically for 16-bit systems)   -    -    -  */
#define FIXDOT    F12DOT4   /* FIXDOT is signed fixed-point F12DOT4*/
#define FIXPOINT  F12POINT  /* F12.4 coordinate-point structure    */
#define IntToFix(intValue)  (FIXDOT)( (intValue) << 4 )
#endif /*FIXDOTxx  * - - - - - - - - - - - - - - - - - - - - - - - */

For additional information on fixed-point types and math functions, please see Appendix A of the Metagraphics Programming Guidelines Manual (.pdf, 235Kb).


Home | Products | Order | Register | Support | Company | Contact | Feedback

Copyright © 1999-2001 - Metagraphics Software Corporation.