Home > Back-end >  An operation can sum for average before you left
An operation can sum for average before you left

Time:09-24

Common bit arithmetic sum
Int the add (int a, int b) {
If (b==0) return a;
Int c=a ^ b;
Int d=(a & amp; B) & lt; <1;
Return to the add (c, d);
}

Also know that for the average (a& (b) + (a ^ b) & gt;> 1) (a + b)/2
The average sum can not beg to shift to the left ((a& (b) + (a ^ b) & gt;> 1)) & lt; <(1) (a + b)/2 * 2

CodePudding user response:

Bit arithmetic used in this place, readability is not good, nor necessary, but you want to study another matter,

CodePudding user response:

Should not, moves to the right may be loss of accuracy, the left back may differ,
  • Related