bug-libmatheval
[Top][All Lists]
Advanced

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

[bug-libmatheval] step function


From: Giulio Bottazzi
Subject: [bug-libmatheval] step function
Date: Fri, 21 Sep 2012 16:08:19 +0200

Hi,
I've got the suspicion I stumbled upon a possible bug... I think it should be step(nan)=nan. The actual implementation


double
math_step(double x)
{
/* 
* Calculate step function value.
*/
return (x < 0) ? 0 : 1;
}

of course gives step(nan)=1.

Alex, what's your opinion? And what about

double
math_step(double x)
{
/* 
 * Calculate step function value.
 */
return isnan(x) ? x : ( x < 0 ? 0 : 1 );
}


G.


--
Giulio Bottazzi <address@hidden>

PGP Key ID:BAB0A33F

reply via email to

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