How to Subtract 1 using Bit Manipulation : Surprising and Important : Bit Manipulation Interview

Опубликовано: 27 Ноябрь 2021
на канале: Firmware
542
9

In this conceptual interview question, we want to Subtract 1 from a number using bit manipulations in C/C++. The answer leads to a surprising connection between 2's complement, Subtraction, and 1's complement. We learn how we can represent 2's complement in different ways. Also, we find some very interesting traits of inversion (1's complement) with regards to its additive property. Have a look!

See Bit Manipulation Interview Preparation Series here:
   • Bit Manipulation Interview Series  
Episode on 2's complement and subtraction:    • Negative number representation, Two's...  

Episode on Addition using Bit Manipulation :    • How to Add 1 without using Plus opera...  

You could follow us on Facebook and Instagram:
Facebook :   / firmwarecode  
Instagram :   / firmwarecode  
#bitmanipulation #bitalgorithm