AP_Math: added unsigned versions of constrain functions

sometimes it really does matter that we use constrain_uint32() instead
of constrain_int32(). For example, if we have a value like 0xFFFFFFFF
then the result will be very different

we should use unsigned constrain when dealing with unsigned values
This commit is contained in:
Andrew Tridgell
2022-04-05 17:46:52 +10:00
parent 82235163a2
commit a95b429acc
3 changed files with 23 additions and 0 deletions
+4
View File
@@ -313,9 +313,13 @@ T constrain_value(const T amt, const T low, const T high)
}
template int constrain_value<int>(const int amt, const int low, const int high);
template unsigned int constrain_value<unsigned int>(const unsigned int amt, const unsigned int low, const unsigned int high);
template long constrain_value<long>(const long amt, const long low, const long high);
template unsigned long constrain_value<unsigned long>(const unsigned long amt, const unsigned long low, const unsigned long high);
template long long constrain_value<long long>(const long long amt, const long long low, const long long high);
template unsigned long long constrain_value<unsigned long long>(const unsigned long long amt, const unsigned long long low, const unsigned long long high);
template short constrain_value<short>(const short amt, const short low, const short high);
template unsigned short constrain_value<unsigned short>(const unsigned short amt, const unsigned short low, const unsigned short high);
template float constrain_value<float>(const float amt, const float low, const float high);
template double constrain_value<double>(const double amt, const double low, const double high);