diff --git a/simgear/structure/SGExpression.hxx b/simgear/structure/SGExpression.hxx index 1f599b76..a2525fc7 100644 --- a/simgear/structure/SGExpression.hxx +++ b/simgear/structure/SGExpression.hxx @@ -665,12 +665,14 @@ public: private: T apply_mods(T property) const { + if( _step <= SGLimits::min() ) return property; + // apply stepping of input value T modprop = floor(property/_step)*_step; // calculate scroll amount (for odometer like movement) - T remainder = property < 0 ? -fmod(property,_step) : (_step - fmod(property,_step)); - if( remainder > 0.0 && remainder < _scroll ) + T remainder = property <= SGLimits::min() ? -fmod(property,_step) : (_step - fmod(property,_step)); + if( remainder > SGLimits::min() && remainder < _scroll ) modprop += (_scroll - remainder) / _scroll * _step; return modprop;