# HG changeset patch # User iive # Date 1309995339 0 # Node ID a5a54c7a15ce91919c65219aa1ffb79f5140c247 # Parent 84defaf2e7f813c78b7162007e93a02d8fc1fbeb Fix the precision loss in float -> 32bit conversion case, introduced by my earlier commit. Instead use method proposed by Reimar. Also, avoid using ldexp, it is slower than multiply with constant. diff -r 84defaf2e7f8 -r a5a54c7a15ce libaf/af_format.c --- a/libaf/af_format.c Tue Jul 05 16:50:52 2011 +0000 +++ b/libaf/af_format.c Wed Jul 06 23:35:39 2011 +0000 @@ -489,15 +489,21 @@ break; case(3): for(i=0;i= 1.0)//no need to use corrected constant, rounding won't cause overflow + ((int32_t*)out)[i] = INT_MAX; + else + ((int32_t*)out)[i] = lrintf(f*2147483648.0); + } break; }