AP_Math: remove warnings from safe_asin()
Return type is float, so operate on float types everywhere. Fixes this warning while building for PX4: ../../libraries/AP_Math/AP_Math.cpp: In instantiation of 'float safe_asin(T) [with T = double]': ../../libraries/AP_Math/AP_Math.cpp:56:48: required from here ../../libraries/AP_Math/AP_Math.cpp:44:11: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion] if (v >= 1.0f) { ^ ../../libraries/AP_Math/AP_Math.cpp:47:11: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion] if (v <= -1.0f) { ^
This commit is contained in:
parent
69a9cd3625
commit
2605c7265b
@ -39,16 +39,17 @@ template bool is_equal<double>(const double v_1, const double v_2);
|
||||
template <class T>
|
||||
float safe_asin(const T v)
|
||||
{
|
||||
if (isnan(static_cast<float>(v))) {
|
||||
const float f = static_cast<const float>(v);
|
||||
if (isnan(f)) {
|
||||
return 0.0f;
|
||||
}
|
||||
if (v >= 1.0f) {
|
||||
if (f >= 1.0f) {
|
||||
return static_cast<float>(M_PI_2);
|
||||
}
|
||||
if (v <= -1.0f) {
|
||||
if (f <= -1.0f) {
|
||||
return static_cast<float>(-M_PI_2);
|
||||
}
|
||||
return asinf(static_cast<float>(v));
|
||||
return asinf(f);
|
||||
}
|
||||
|
||||
template float safe_asin<int>(const int v);
|
||||
|
Loading…
Reference in New Issue
Block a user