Commit b0584617 authored by Loic Hausammann's avatar Loic Hausammann Committed by Matthieu Schaller
Browse files

Clarify box_wrap

parent f05bd301
......@@ -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); \
})
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment