mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
mathlib: int16_t negate explicitly handle both INT16_MIN and INT16_MAX
- technically negating INT16_MAX doesn't need special handling, but this ensures any simple saturation logic downstream works by default
This commit is contained in:
parent
d59d16a6cd
commit
ecc2ca7f98
@ -227,7 +227,14 @@ constexpr T negate(T value)
|
||||
template<>
|
||||
constexpr int16_t negate<int16_t>(int16_t value)
|
||||
{
|
||||
return (value == INT16_MIN) ? INT16_MAX : -value;
|
||||
if (value == INT16_MAX) {
|
||||
return INT16_MIN;
|
||||
|
||||
} else if (value == INT16_MIN) {
|
||||
return INT16_MAX;
|
||||
}
|
||||
|
||||
return -value;
|
||||
}
|
||||
|
||||
inline bool isFinite(const float &value)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user