mirror of
https://gitlab.com/80486DX2-66/gists
synced 2024-12-26 02:29:50 +05:30
opt_int_div.h: make comments more descriptive
This commit is contained in:
parent
5049a3977e
commit
98f020413f
@ -22,19 +22,20 @@
|
||||
#define OPT_INT_DIV_TEST(b) \
|
||||
/* check if b is a power of 2 */ \
|
||||
/* */ \
|
||||
/* formula: ( X & (X - 1) ) == 0 */ \
|
||||
/* condition: ( X & (X - 1) ) == 0 */ \
|
||||
((b) & ((b) - 1)) == 0
|
||||
|
||||
// the main macro
|
||||
#define OPT_INT_DIV(a, b) \
|
||||
( /* beginning */ \
|
||||
/* check for equality of a and b */ \
|
||||
/* check for equality of abs(a) and abs(b) */ \
|
||||
INT_ABS((a)) == INT_ABS((b)) ? \
|
||||
/* the result is +/-1 */ \
|
||||
(INT_DIV_NEG_RESULT_SIGN(a, b) ? -1 : 1) : ( \
|
||||
\
|
||||
/* check if abs(a) < abs(b) */ \
|
||||
INT_ABS((a)) < INT_ABS((b)) ? \
|
||||
/* if abs(a) < abs(b), then the result is less than 1 (i.e., 0) */\
|
||||
0 : ( \
|
||||
\
|
||||
OPT_INT_DIV_TEST((b)) ? \
|
||||
|
Loading…
Reference in New Issue
Block a user