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 20:28:28 +0000

Thanks for reminding me of the dangers of macros :)
        Josh

On Mon, 2006-12-11 at 14:58 +0000, Paul Millar wrote:
> On Monday 11 December 2006 14:24, Josh Green wrote:
> > 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)
> [..]
> > > 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))
> 
> You'd need parentheses around the x characters in the expansion.  Even then, 
> its slightly dangerous:
> 
> y = roundi( sin(x));
> 
> results in two evaluations of sin(x).  The quintessential bad one is:
> 
> y = roundi( x++);
> 
> }:->
> 
> Cheers,
> 
> Paul.





reply via email to

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