fluid-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [fluid-dev] Re: Changes checked into CVS


From: Josh Green
Subject: Re: [fluid-dev] Re: Changes checked into CVS
Date: Mon, 11 Dec 2006 14:24:38 +0000

On Mon, 2006-12-11 at 00:19 +0200, Mihail Zenkov wrote:
> IMHO better replace roundf with this code in all case:
> 
> inline int roundi(float x)
> {
>         if (x >= 0.0f)
>                 return (int)(x+0.5f);
>         else
>                 return (int)(x-0.5f);
> }
> 
> It slightly faster then gcc roundf (1.5 time).
> 

Sounds good, will also be more portable :)  I suppose a macro such as
this would also do the trick?

#define roundi(x)   ((x >= 0.0f) ? (int)(x+0.5f) : (int)(x-0.5f))

I'd expect a builtin gcc function to be faster, but I have found in the
past that also to not be true.  memcpy for example, I found to be slower
than a simple loop.  Perhaps that is only for smaller sizes though.
Thanks again.
        Josh






reply via email to

[Prev in Thread] Current Thread [Next in Thread]