educative.io

Educative

Convert Decimal Number to Binary Number - Grokking Bit Manipulation

I am confused why approach # 3 is more optimal than approach # 1.
Both of them are doing shift operations. What makes approach#3 more optimal?

Hey @subhasmita

In the 1st approach, Right-shift technique is used which shifts the bit from right to left, whereas in the 3rd approach Left-shift technique is used which shifts the bit from left to right which is an optimal solution and produces output faster than 1st approach.

Happy learning,