Answer to Question #27865 in C++ for asha

Question #27865
a=a-~b-1; how this works please explain
1
Expert's answer
2013-04-10T09:15:16-0400
"~" in C++ is bitwise operation NOT. Thebitwise NOT, or complement, is an unary operation that performs logical
negation on each bit, forming the ones' complement of the given binary value.
Bits that are
0 become 1, and those that are 1 become 0. The bitwisecomplement is equal to the two's complement of the value minus one. If two's
complement arithmetic is used, then ~x = - x - 1.
In your case
a = a - ~b - 1 = a - (-b + 1) - 1 = a + b;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS