From 98440cba734ae198a813f078a2f81efafefa8725 Mon Sep 17 00:00:00 2001 From: Metin Cakircali Date: Tue, 21 Nov 2023 14:19:46 +0100 Subject: [PATCH] add support for by < 0 --- src/metkit/mars/TypeToByListFloat.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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++;