diff --git a/src/metkit/mars/TypeToByListFloat.cc b/src/metkit/mars/TypeToByListFloat.cc index 3450cb0..ee7a9de 100644 --- a/src/metkit/mars/TypeToByListFloat.cc +++ b/src/metkit/mars/TypeToByListFloat.cc @@ -61,11 +61,14 @@ void TypeToByListFloat::expand(const MarsExpandContext& ctx, std::vector 0, name_ + ": [" + std::to_string(by) + "] value must be a positive number!"); - for (float j = from + by; j <= to; j += by) { - newval.push_back(l2s(j)); + if (by > 0) { + ASSERT_MSG(from <= to, name_ + ": [" + std::to_string(from) + "] value must be less than [" + + std::to_string(to) + "] value!"); + for (float j = from + by; j <= to; j += by) { newval.push_back(l2s(j)); } + } else if (by < 0) { + ASSERT_MSG(from >= to, name_ + ": [" + std::to_string(from) + "] value must be greater than [" + + std::to_string(to) + "] value!"); + for (float j = from + by; j >= to; j += by) { newval.push_back(l2s(j)); } } i++;