at 27:40 what is happening in
p=safe & (-safe);
safe=safe-p;
and can you please explain about the 1’s(-) and 2’s(~) complement and their relation
at 27:40 what is happening in
p=safe & (-safe);
safe=safe-p;
and can you please explain about the 1’s(-) and 2’s(~) complement and their relation
@SATVIK
In statement
p=safe & (-safe);
P gives 2^(last set bit in safe) as value
safe = safe - p subtracts last set bit from number
For detailed explanation please see https://www.geeksforgeeks.org/count-set-bits-in-an-integer/
Method 2
If your doubt is resolved please mark it as closed.
sorry, couldn’t get it
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.