16 #define IEEE754_MANTISSA_MASK (0x7fffff)
17 #define IMPLICIT_ONE (0x800000)
18 #define IEEE754_EXPONENT(n) ((int32)((n)>>23) & 0xff)
19 #define IEEE754_MANTISSA(n) ((int32)(n) & IEEE754_MANTISSA_MASK)
20 #define IEEE754_SIGN(n) (((uint32)(n))>>31)
40 shift = (I - e - 1) + (24 - W);
47 if (shift < (24 - W + S)) (*status)++;
58 #ifdef COMPILE_TEST_FUNCTIONS
69 static AcFixed_t fnums[] = {
70 { .num= 15.356789, .W=16, .I=2, .S=0},
71 { .num= 1.356789, .W=16, .I=2, .S=0},
72 { .num= 0.00356789,.W=16, .I=2, .S=0},
73 { .num= 500.0, .W=16, .I=8, .S=1},
74 { .num=-500.0, .W=16, .I=8, .S=1},
75 { .num= 1.0, .W=16, .I=8, .S=1},
76 { .num= -1.0, .W=16, .I=8, .S=1},
77 { .num= 2.5, .W=16, .I=8, .S=1},
78 { .num= -2.5, .W=16, .I=8, .S=1},
79 { .num= 37.5, .W=16, .I=8, .S=1},
80 { .num= 112.9875, .W=16, .I=8, .S=1},
81 { .num= 360.0, .W=16, .I=8, .S=1},
82 { .num= 249.1231232, .W=16, .I=8, .S=1},
83 { .num= -45.965, .W=16, .I=8, .S=1},
84 { .num= -27.8, .W=16, .I=8, .S=1},
85 { .num= -25.0, .W=16, .I=8, .S=1},
86 { .num=-279.2, .W=16, .I=8, .S=1},
87 { .num=-360.0, .W=16, .I=8, .S=1}
90 void test_fixed_point()
96 for (i=0; i <
sizeof(fnums)/
sizeof(AcFixed_t); i++ )
#define IEEE754_MANTISSA(n)
#define IEEE754_EXPONENT(n)
unsigned short int uint16
uint32 float32_To_AcFixed(float fN, uint8 W, uint8 I, uint8 S, int32 *status)
This function converts an IEEE-754 32-bit floating point number into a fixed point integer format...