Skip to content
Snippets Groups Projects
Commit c25515f3 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Merge branch 'change_box_wrap' into 'master'

Clarify box_wrap

See merge request !939
parents f05bd301 b0584617
No related branches found
No related tags found
1 merge request!939Clarify box_wrap
......@@ -28,15 +28,15 @@
/**
* @brief Limits the value of x to be between a and b
*
* Only wraps once. If x > 2b, the returned value will be larger than b.
* Similarly for x < -b.
* Only wraps once. If x > a + 2(b - a), the returned value will be larger than
* b. Similarly for x < a - (b - a), the value will be smaller than a.
*/
#define box_wrap(x, a, b) \
({ \
const __typeof__(x) _x = (x); \
const __typeof__(a) _a = (a); \
const __typeof__(b) _b = (b); \
_x < _a ? (_x + _b) : ((_x >= _b) ? (_x - _b) : _x); \
#define box_wrap(x, a, b) \
({ \
const __typeof__(x) _x = (x); \
const __typeof__(a) _a = (a); \
const __typeof__(b) _b = (b); \
_x < _a ? (_x + (_b - _a)) : ((_x >= _b) ? (_x - (_b - _a)) : _x); \
})
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment