[FFmpeg-devel] [PATCH] djgpp port

Michael Kostylev mik
Wed Dec 26 22:03:31 CET 2007


At Wed, 26 Dec 2007 19:12:16 +0100,
Michael Niedermayer wrote:

>>>> +#ifndef HAVE_ROUND
>>>> +static av_always_inline double round(double x)
>>>> +{
>>>> +    return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
>>>> +}
>>>> +#endif /* HAVE_ROUND */
>>> iam ok with this, though if i were picky i could complain that
>>> your round implementation fails for 0.49999999999999994449 amongth others
>>> but i guess its good enough. Fixing that would make it slower and
>>> uglier with no real advantage ...
>> IIRC the glibc round has the same behavior inside the __DBL_EPSILON__ neighborhood of x.5.
> not here, just try:
> #define _ISOC99_SOURCE
> #include <math.h>
> #include <stdio.h>
> main(){
>     printf("%f %f\n", round(0.49999999999999994449), floor(0.49999999999999994449 + 0.5));
>     printf("%f %f\n", round(4503599627370497.0), floor(4503599627370497.0 + 0.5));
> }
>> In addition you could complain that my fake round uses uncommon rounding mode.
> not sure what you mean ...

Sorry, I skipped your "amongth others". Round() works exactly like it should.

Michael




More information about the ffmpeg-devel mailing list