60 721
Assignments Done
97,9%
Successfully Done
In April 2018

Answer to Question #27865 in C++ for asha

Question #27865
a=a-~b-1; how this works please explain
Expert's answer
"~" 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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions