Converting binary to decimal

i have written a function which converts binary in Linked List to decimal. I have one confusion, it gives wrong answer with left shift operator(<<), but works correctly if using power function, pls help and explain the difference between left shift operator and power function with regards to this question.


just look at the getDecimalValue function, the rest code is just for building Linked List.

@skaushik.46 left shift operator is equivalent to multiplying by 2. In decimal to binary conversion, you need powers of 2, which cannot be done through the left shift operator.

please look into the code properly, i am changing the value of i while using left shift operator, which implies multiplying by 2 again and again i number of times, so what is going wrong there, pls provide a proper explanation regarding this doubt.

@skaushik.46 please do a dry run of your code you will see where this is going wrong, its a very simple code so you can dry run easily still if you are facing any problem in dry run please let me know