mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-09 22:49:53 +08:00
Bound function also bounds NaN (#3118)
* Bound function also bounds nan * Update comment Co-authored-by: Christophe De Wagter <dewagter@gmail.com> * Bound defaults to min in case of NaN --------- Co-authored-by: Christophe De Wagter <dewagter@gmail.com>
This commit is contained in:
+2
-1
@@ -135,8 +135,9 @@ typedef uint8_t unit_t;
|
||||
|
||||
#define BoundUpper(_x, _max) { if (_x > (_max)) _x = (_max);}
|
||||
|
||||
// Note: the bound function will bound NaN to min as any comparison that contains NaN is false.
|
||||
#define Bound(_x, _min, _max) { if (!(_x > (_min))) _x = (_min); else if (!(_x < (_max))) _x = (_max); }
|
||||
|
||||
#define Bound(_x, _min, _max) { if (_x > (_max)) _x = (_max); else if (_x < (_min)) _x = (_min); }
|
||||
#define BoundInverted(_x, _min, _max) { \
|
||||
if ((_x < (_min)) && (_x > (_max))) { \
|
||||
if (abs(_x - (_min)) < abs(_x - (_max))) \
|
||||
|
||||
Reference in New Issue
Block a user