On Tue, Nov 14, 2006 at 11:08:29AM +0000, Bastiaan Jacques wrote:

> +#ifndef trunc
> +#define trunc(a) static_cast<long>(a)
> +#endif

mmm... the manual page says:

       These  functions  round x to the nearest integer not larger in absolute
       value.

So I'd assume:

        orig    trunc
        -1.2    -1
         1.2     1
        -2.9    -2
         3.9     2

Now, the trunc() function takes and returns a 'double' type so we
must make sure we don't overflow the 'long' type.

BTW, floor does just that if we make sure we swap sign:

#define TRUNC(x) ( x < 0 ?  -floor(-x) : floor(x) )

tested:

 1.2: floor=1 trunc=1 TRUNC=1
-1.2: floor=-2 trunc=-1 TRUNC=-1
 1.9: floor=1 trunc=1 TRUNC=1
-1.9: floor=-2 trunc=-1 TRUNC=-1
 1.5: floor=1 trunc=1 TRUNC=1
-1.5: floor=-2 trunc=-1 TRUNC=-1


--strk;


_______________________________________________
Gnash-commit mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnash-commit

Reply via email to