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

Michael Niedermayer michaelni
Thu Mar 22 17:20:17 CET 2007


Hi

On Thu, Mar 22, 2007 at 10:18:04AM -0500, Rich Felker wrote:
> On Thu, Mar 22, 2007 at 11:47:01AM +0100, Michael Niedermayer wrote:
> > to factor out the pow() your needing algebraic identities depends on how pow
> > is defined either way the associative law for multiplication is enough and
> 
> 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

besides this, in the example it was a pow() gcc should have removed and there
such a overflow wont happen unless the result is very very close to 
overflowing itself but that alone due to floats being a non exact things makes
the result undefined, so i really dont see why gcc shouldnt be able to replace
pow() there the only argument would be slight loss of accuracy with very
large exponents but the exponent was bounded <50 in that case ...

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/attachments/20070322/cc8ba60b/attachment.pgp>



More information about the ffmpeg-cvslog mailing list