4545
4646#ifdef FIXED_POINT
4747#define WORD "%d"
48- #define FIX_INT_TO_DOUBLE (x ,q ) (( double)(x) / (double)(1L << q ))
49- #define DOUBLE_TO_FIX_INT (x ,q ) (((double)x * (double)(1L << q)))
48+ #define FIX_INT_TO_DOUBLE (x ,q ) (ldexp(( double)(x), -(q) ))
49+ #define DOUBLE_TO_FIX_INT (x ,q ) (ldexp ((double)(x), ( q)))
5050#else
5151#define WORD "%f"
5252#endif
@@ -68,7 +68,7 @@ void testdiv(void)
6868#endif
6969 if (fabs (prod - 1 ) > .00025 )
7070 {
71- fprintf (stderr , "div failed: 1/%d=" WORD " (product = %f)\n" , i , val , prod );
71+ fprintf (stderr , "div failed: 1/%d=" WORD " (product = %f)\n" , i , val , prod );
7272 ret = 1 ;
7373 }
7474 }
@@ -85,7 +85,7 @@ void testsqrt(void)
8585 ratio = val /sqrt (i );
8686 if (fabs (ratio - 1 ) > .0005 && fabs (val - sqrt (i )) > 2 )
8787 {
88- fprintf (stderr , "sqrt failed: sqrt(%d)=" WORD " (ratio = %f)\n" , i , val , ratio );
88+ fprintf (stderr , "sqrt failed: sqrt(%d)=" WORD " (ratio = %f)\n" , i , val , ratio );
8989 ret = 1 ;
9090 }
9191 i += i >>10 ;
@@ -178,7 +178,7 @@ void testexp2(void)
178178 float max_error = 0 ;
179179 for (x = -11.0 ;x < 24.0 ;x += 0.0007f )
180180 {
181- float error = fabs (x - (1.442695040888963387 * log (celt_exp2 (x ))));
181+ float error = fabs (x - (1.442695040888963387 * log (( double ) celt_exp2 (x ))));
182182 if (max_error < error )
183183 {
184184 max_error = error ;
@@ -259,7 +259,7 @@ void test_atan2(void) {
259259 /* atan2(0,0) is undefined behavior. */
260260 continue ;
261261 }
262- float error = fabs (0.636619772367581f * (float )atan2 (y , x ) - celt_atan2p_norm (y , x ));
262+ float error = fabs (0.636619772367581f * (float )atan2 (( double ) y , ( double ) x ) - celt_atan2p_norm (y , x ));
263263 if (max_error < error )
264264 {
265265 max_error = error ;
@@ -332,7 +332,7 @@ void testexp2(void)
332332 float error2 = fabs (exp (0.6931471805599453094 * x /1024.0 )- celt_exp2 (x )/65536.0 );
333333 if (error1 > 0.0002 && error2 > 0.00004 )
334334 {
335- fprintf (stderr , "celt_exp2 failed: x = " WORD ", error1 = %f, error2 = %f\n" , x ,error1 ,error2 );
335+ fprintf (stderr , "celt_exp2 failed: x = " WORD ", error1 = %f, error2 = %f\n" , x ,error1 ,error2 );
336336 ret = 1 ;
337337 }
338338 }
@@ -425,7 +425,7 @@ void testrsqrt(void)
425425 x = DOUBLE_TO_FIX_INT (fx , 31 );
426426 quantized_fx = FIX_INT_TO_DOUBLE (x , 31 );
427427 error = fabs (FIX_INT_TO_DOUBLE (celt_rsqrt_norm32 (x ), 29 ) -
428- 1 /sqrt (quantized_fx ));
428+ 1 /sqrt (( double ) quantized_fx ));
429429 if (max_error < error )
430430 {
431431 max_error = error ;
0 commit comments