Fixed bug with step() function (thanks to Giulio Bottazzi). - libmatheval.git -

summary refs log tree commit diff
path: root/lib/xmath.c
diff options
context:
space:
mode:
authorAleksandar Samardžić <asamardzic@matf.bg.ac.rs>2012年09月22日 14:11:43 +0200
committerAleksandar Samardžić <asamardzic@matf.bg.ac.rs>2012年09月22日 14:11:43 +0200
commit5028e622b62303401c74d9aa0976e19ed2f6eb34 (patch)
treea21d55edc6cee332b54785f877229fa7a0cbb3ff /lib/xmath.c
parent02df692a94039d69fe0292ab05f5f596304333e5 (diff)
downloadlibmatheval-5028e622b62303401c74d9aa0976e19ed2f6eb34.tar.gz
Fixed bug with step() function (thanks to Giulio Bottazzi).
Diffstat (limited to 'lib/xmath.c')
-rw-r--r--lib/xmath.c 6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/xmath.c b/lib/xmath.c
index 1310b2f..1bd5f81 100644
--- a/lib/xmath.c
+++ b/lib/xmath.c
@@ -162,7 +162,7 @@ math_step(double x)
/*
* Calculate step function value.
*/
- return (x < 0) ? 0 : 1;
+ return MATH_ISNAN(x) ? x : ((x < 0) ? 0 : 1);
}
double
@@ -171,7 +171,7 @@ math_delta(double x)
/*
* Calculate delta function value.
*/
- return (x == 0) ? MATH_INFINITY : 0;
+ return MATH_ISNAN(x) ? x : ((x == 0) ? MATH_INFINITY : 0);
}
double
@@ -180,5 +180,5 @@ math_nandelta(double x)
/*
* Calculate modified delta function value.
*/
- return (x == 0) ? MATH_NAN : 0;
+ return MATH_ISNAN(x) ? x : ((x == 0) ? MATH_NAN : 0);
}
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月06日 08:49:50 +0000

AltStyle によって変換されたページ (->オリジナル) /