Skip to content

Commit

Permalink
AP_Math: correct warning on fabsF
Browse files Browse the repository at this point in the history
2024-08-08T01:51:53.6780446Z ../../libraries/AP_Math/vector3.cpp:432:9: warning: absolute value function 'fabsf' given an argument of type 'const double' but has parameter of type 'float' which may cause truncation of value [-Wabsolute-value]
2024-08-08T01:51:53.6781336Z     if (fabsF(cosv) >= 1) {
2024-08-08T01:51:53.6781583Z         ^
2024-08-08T01:51:53.6781930Z ../../libraries/AP_Math/ftype.h:50:18: note: expanded from macro 'fabsF'
2024-08-08T01:51:53.6782342Z #define fabsF(x) fabsf(x)
2024-08-08T01:51:53.6782572Z                  ^
2024-08-08T01:51:53.6789178Z ../../libraries/AP_Math/vector3.cpp:633:16: note: in instantiation of member function 'Vector3<double>::angle' requested here
2024-08-08T01:51:53.6789800Z template class Vector3<double>;
  • Loading branch information
peterbarker authored and tridge committed Aug 13, 2024
1 parent 08bf7c6 commit 6c788c6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libraries/AP_Math/vector3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ T Vector3<T>::angle(const Vector3<T> &v2) const
return 0.0f;
}
const T cosv = ((*this)*v2) / len;
if (fabsF(cosv) >= 1) {
if (cosv >= 1 || cosv <= -1) {
return 0.0f;
}
return acosF(cosv);
Expand Down

0 comments on commit 6c788c6

Please sign in to comment.