diff --git a/JSBSim.xsd b/JSBSim.xsd
index 1a4b545a9..d4f05487d 100644
--- a/JSBSim.xsd
+++ b/JSBSim.xsd
@@ -1426,6 +1426,7 @@
+
@@ -1625,7 +1626,15 @@
-
+
+
+
+
+
+
+
+
+
diff --git a/src/math/FGFunction.cpp b/src/math/FGFunction.cpp
index 36ce0e2d2..d0ac0fa33 100644
--- a/src/math/FGFunction.cpp
+++ b/src/math/FGFunction.cpp
@@ -527,6 +527,15 @@ void FGFunction::Load(Element* el, FGPropertyValue* var, FGFDMExec* fdmex,
return y != 0.0 ? fmod(p[0]->GetValue(), y) : HUGE_VAL;
};
Parameters.push_back(new aFunc(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
+ Parameters.push_back(new aFunc(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());
diff --git a/src/math/FGFunction.h b/src/math/FGFunction.h
index 3086e09e5..8b398ebae 100644
--- a/src/math/FGFunction.h
+++ b/src/math/FGFunction.h
@@ -88,6 +88,7 @@ A function definition consists of an operation, a value, a table, or a property
- floor (takes 1 arg)
- ceil (takes 1 arg)
- fmod (takes 2 args)
+- roundmultiple (takes 2 args)
- lt (less than, takes 2 args)
- le (less equal, takes 2 args)
- gt (greater than, takes 2 args)
@@ -511,6 +512,15 @@ refers to one or more instances of a property, value, or table.
@endcode
Example: fmod(18.5, 4.2) evaluates to 1.7
+- @b roundmultiple returns the floating-point rounding of X to a multiple of M.
+ round(X/M) * M
+ @code
+
+ {property, value, table, or other function element}
+ {property, value, table, or other function element}
+
+ @endcode
+ Example: roundmultiple(93.43, 5.0) evaluates to 95.0
- @b lt returns a 1 if the value of the first immediate child element is less
than the value of the second immediate child element, returns 0
otherwise