[Ffmpeg-cvslog] r8474 - trunk/libavcodec/resample2.c

Rich Felker dalias
Thu Mar 22 18:33:49 CET 2007


On Thu, Mar 22, 2007 at 06:39:16PM +0200, Uoti Urpala wrote:
> On Thu, 2007-03-22 at 17:20 +0100, Michael Niedermayer wrote:
> > On Thu, Mar 22, 2007 at 10:18:04AM -0500, Rich Felker wrote:
> > > Associative law is false with floats. Think of
> > > 
> > > A = FLOAT_MAX
> > > B = FLOAT_MAX
> > > C = 1.0/FLOAT_MAX
> > 
> > yes i did think of it, and i just tested:
> > ------
> > #include <float.h>
> > #include <stdio.h>
> > 
> > float a= FLT_MAX;
> > float b= FLT_MAX;
> > float c= 1.0/FLT_MAX;
> > 
> > main(){
> >     printf("%f %f\n", (a*b)*c, a*(b*c));
> > }
> > ------
> > output is:
> > 340282326356120465085853374166440345600.000000 340282326356120465085853374166440345600.000000
> > even with gcc -O0
> 
> That's because you used floats but gcc kept the variables in FPU
> registers. Try it with long doubles or use -ffloat-store.

Won't help. All floating point expressions are actually double or
larger in C. You'll need to explicitly cast to (float) after the
multiplications to avoid it.

Rich




More information about the ffmpeg-cvslog mailing list