# fx16 Type Macros

## Description

FX16_SHIFT | Defines the shift number (12) for `fx16` types.
FX16_INT_SIZE | Defines the bit width of the integer portion (3) for `fx16` types.
FX16_DEC_SIZE | Defines the bit width for the decimal portion (12) for `fx16` types.
FX16_INT_MASK | Defines the mask (`0x7000`) for the integer portion of `fx16` types.
FX16_DEC_MASK | Defines the mask (`0x0fff`) for the decimal portion of `fx16` types.
FX16_SIGN_MASK | Defines the mask (`0x8000`) for the sign portion of `fx16` types.
FX16_MAX | Defines the maximum value (`0x7fff`) that can be obtained with `fx16` types.
FX16_MIN | Defines the minimum value (`0x8000`) that can be obtained with `fx16` types.
FX_FX16_TO_F32 | Converts an fx16 type to an f32 type.
FX_F32_TO_FX16 FX16_CONST | Converts an f32 type to an fx16 type.

## Macro Definitions

    #define FX16_SHIFT          12
    #define FX16_INT_SIZE       3
    #define FX16_DEC_SIZE       12

    #define FX16_INT_MASK       0x7000
    #define FX16_DEC_MASK       0x0fff
    #define FX16_SIGN_MASK      0x8000

    #define FX16_MAX            (fx16)(0x7fff)
    #define FX16_MIN            (fx16)(0x8000)
    #define FX_FX16_TO_F32(x)    ((f32)((x) / (f32)(1 << FX16_SHIFT)))
    #define FX_F32_TO_FX16(x)    ((fx16)(((x) > 0) ?
    (fx16)((x) * (1 << FX16_SHIFT) + 0.5f ) :
    (fx16)((x) * (1 << FX16_SHIFT) - 0.5f )))

    #define FX16_CONST(x)       FX_F32_TO_FX16(x)

## Revision History

02/25/2004 Initial version.

CONFIDENTIAL