summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-10-01 07:48:53 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-10-01 07:48:53 +0200
commitd626a60eca7a511786435ec796d7864c59463939 (patch)
treee8c0d068b7fbd51bb0519164c38a6b97302c0081
parent236c63fe4bc507d226c424559c5f65b5679eefa3 (diff)
accela: guard against negative value overflow properly
Accela attempted to guard against both negative and positive value overstepping the last value due to gain, but the check for negative values was incorrect. Issue: #231 Reported-by: @nanospork, @alterscape, @SgtGrumbles
-rw-r--r--ftnoir_filter_accela/ftnoir_filter_accela.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp
index b246a925..7f1d9d0a 100644
--- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp
+++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp
@@ -97,7 +97,7 @@ void FTNoIR_Filter::filter(const double* input, double *output)
const double thres = i >= 3 ? rot_t : trans_t;
const double val = m.getValue(vec_ / thres);
const double result = last_output[i] + (vec < 0 ? -1 : 1) * dt * val;
- const bool negp = vec < 0.;
+ const bool negp = in < 0.;
const bool done = negp
? result <= in
: result >= in;