DEV Community

Cover image for What's Bit Manipulation?
Aishanii
Aishanii

Posted on

What's Bit Manipulation?

Bit Manipulation- https://450dsa.com/bit_manipulation

For X and Y such that
X/2=Y

Example:

- 7/2=3

7->111 (3)
3->011 (2)
Enter fullscreen mode Exit fullscreen mode

- 12/2=6

12->1100 (2)
6->0110 (2)
Enter fullscreen mode Exit fullscreen mode

If the X is ODD

It will have the least significant bit set. Hence dividing by 2, will be right shifting

If the X is EVEN

Its least significant bit will not be set hence dividing by 2 will have no effect on number of set bits as only 0 will be lost.

So if the number if the X is ODD,

number of set bits of X = 1 + Y

But when X is even,

number of set bits of X = Y

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series πŸ“Ί

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series πŸ‘€

Watch the Youtube series

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay