summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fixpow.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/fixpow.c b/fixpow.c
index 3db6df3..a023f7a 100644
--- a/fixpow.c
+++ b/fixpow.c
@@ -256,10 +256,16 @@ int main()
256 256
257 // Testing fixexp 257 // Testing fixexp
258 for (input=-2147483648; input < TO_Q26(10.39720770839918); ++input ) { 258 for (input=-2147483648; input < TO_Q26(10.39720770839918); ++input ) {
259 int32_t expected = TO_Q16(exp(FROM_Q26(input))); 259 double expected = exp(FROM_Q26(input));
260 int32_t output = fixexp(input); 260 int32_t expected_int = TO_Q16(expected);
261 if( abs(output-expected) > 16 ) 261 int32_t output_int = fixexp(input);
262 printf( "%08X : %08X = %08X (%08d)\n", output, expected, abs(output-expected), input ); 262 double output = FROM_Q16(output_int);
263 if( abs(output_int-expected_int) > 8 ) {
264 if( expected > output && output > 0 && expected / output > 1.002 )
265 printf( "%08X : %08X = %08X (%08d)\n", output_int, expected_int, abs(output_int-expected_int), input );
266 if( expected < output && expected > 0 && output / expected > 1.002 )
267 printf( "%08X : %08X = %08X (%08d)\n", output_int, expected_int, abs(output_int-expected_int), input );
268 }
263 } 269 }
264 270
265 printf( "pow(%lf,%lf)=%lf (%s)\n", base, exponent, FROM_Q16(result), error?"ERROR":"OK" ); 271 printf( "pow(%lf,%lf)=%lf (%s)\n", base, exponent, FROM_Q16(result), error?"ERROR":"OK" );