Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify code slightly in roundmultiple #1172

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/math/FGFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,15 @@
};
Parameters.push_back(new aFunc<decltype(f), 2>(f, fdmex, element, Prefix, var));
} else if (operation == "roundmultiple") {
auto f = [](const decltype(Parameters)& p)->double {
double multiple = p.size() == 1 ? 1.0 : p[1]->GetValue();
return round((p[0]->GetValue() / multiple)) * multiple;
};
if (element->GetNumElements() == 1)
Parameters.push_back(make_MathFn(round, fdmex, element, Prefix, var));
else
else {
auto f = [](const decltype(Parameters)& p)->double {
double multiple = p[1]->GetValue();
return round((p[0]->GetValue() / multiple)) * multiple;

Check warning on line 536 in src/math/FGFunction.cpp

View check run for this annotation

Codecov / codecov/patch

src/math/FGFunction.cpp#L534-L536

Added lines #L534 - L536 were not covered by tests
};
Parameters.push_back(new aFunc<decltype(f), 1>(f, fdmex, element, Prefix, var, 2));
}
} else if (operation == "atan2") {
auto f = [](const decltype(Parameters)& p)->double {
return atan2(p[0]->GetValue(), p[1]->GetValue());
Expand Down
Loading