void main(void)
{
bVal = TRUE; /* bVal = TRUE */
}
A.20 FRAC8
The
macro serves to convert a real number to the
type. Its definition is as
follows:
#define FRAC8(x) ((frac8_t)((x) < 0.9921875 ? ((x) >= -1 ? (x)*0x80 : 0x80) : 0x7F))
The input is multiplied by 128 (=2
7
). The output is limited to the range <0x80 ; 0x7F>,
which corresponds to <-1.0 ; 1.0-2
-7
>.
#include "mlib.h"
static frac8_t f8Val;
void main(void)
{
f8Val = FRAC8(0.187); /* f8Val = 0.187 */
}
A.21 FRAC16
The
macro serves to convert a real number to the
type. Its definition is
as follows:
#define FRAC16(x) ((frac16_t)((x) < 0.999969482421875 ? ((x) >= -1 ? (x)*0x8000 : 0x8000) :
0x7FFF))
The input is multiplied by 32768 (=2
15
). The output is limited to the range <0x8000 ;
0x7FFF>, which corresponds to <-1.0 ; 1.0-2
-15
>.
#include "mlib.h"
static frac16_t f16Val;
void main(void)
{
f16Val = FRAC16(0.736); /* f16Val = 0.736 */
}
Appendix A Library types
GMCLIB User's Guide, Rev. 2, 10/2015
Freescale Semiconductor, Inc.
75
Содержание DSP56800E
Страница 1: ...GMCLIB User s Guide DSP56800E Document Number DSP56800EGMCLIBUG Rev 2 10 2015 ...
Страница 2: ...GMCLIB User s Guide Rev 2 10 2015 2 Freescale Semiconductor Inc ...
Страница 4: ...GMCLIB User s Guide Rev 2 10 2015 4 Freescale Semiconductor Inc ...
Страница 64: ...GMCLIB_SvmU7n GMCLIB User s Guide Rev 2 10 2015 64 Freescale Semiconductor Inc ...
Страница 78: ...GMCLIB User s Guide Rev 2 10 2015 78 Freescale Semiconductor Inc ...