[PD-dev] [PATCH] Avoid crash in vd~ for nan/inf input values
Miller Puckette
msp at ucsd.edu
Fri Sep 13 00:00:03 CEST 2013
THanks all for this... I went ahead and patched it (Claude's way, but with
an explanatory comment :)
On Wed, Sep 11, 2013 at 08:53:12PM +0200, Kjetil Matheussen wrote:
> On Tue, Sep 10, 2013 at 8:40 PM, Claude Heiland-Allen
> <claude at mathr.co.uk> wrote:
> > Hi Kjetil,
> >
> > In my own code I tend to exploit the incomparibility of NaN.
> >
> > Instead of:
> >
> > if (x < lo) x = lo;
> > if (x > hi) x = hi;
> >
> > I write:
> >
> > if (! (x >= lo)) x = lo;
> > if (! (x <= hi)) x = hi;
> >
> > As any comparison with NaN gives false, the first version will pass NaN
> > through unchanged, but the second version will replace NaN with lo.
> > Behaviour with finite values and +/-Infinity should remain the same as
> > the first version.
> >
>
> Hi Claude,
>
> That is a nice solution, but is
>
> "
> if (! (x >= lo)) x = lo;
> if (! (x <= hi)) x = hi;
> "
>
> reallly faster than
>
> "
> if(!isfinite(x))
> x = 0.0f;
> if (x < lo) x = lo;
> if (x > hi) x = hi;
> "
>
> ?
>
> If not, the second option is much clearer.
>
> _______________________________________________
> Pd-dev mailing list
> Pd-dev at iem.at
> http://lists.puredata.info/listinfo/pd-dev
More information about the Pd-dev
mailing list