Skip to content

Commit

Permalink
add support for by < 0
Browse files Browse the repository at this point in the history
  • Loading branch information
mcakircali committed Nov 21, 2023
1 parent dd3f2be commit 98440cb
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/metkit/mars/TypeToByListFloat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ void TypeToByListFloat::expand(const MarsExpandContext& ctx, std::vector<std::st
i += 2;
}

ASSERT_MSG(from <= to, name_ + ": [" + std::to_string(from) + "] value must be less than [" +
std::to_string(to) + "] value!");
ASSERT_MSG(by > 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++;
Expand Down

0 comments on commit 98440cb

Please sign in to comment.