Explain is it better to bitshift a value than to multiply by 2?



Explain is it better to bitshift a value than to multiply by 2?..

Answer / Sonmati Gupta

Bitshifting can be more efficient than multiplication by 2 for integer arithmetic operations in C, as shifting requires fewer CPU cycles compared to multiplication. However, this advantage only applies when working with powers of 2 and can vary based on the specific hardware and compiler optimizations.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What is floating point exception error? And what are different types of errors occur during compile time and run time? why they occur?

1 Answers  


implement general tree using link list

1 Answers   Wipro,


What is a 'null pointer assignment' error?

1 Answers  


Explain how do you sort filenames in a directory?

1 Answers  


Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?

1 Answers  


how does a general function , that accepts an array as a parameter, "knows" the size of the array ? How should it define it parameters list ?

2 Answers   Patni, TCS,


What are conditional operators in C?

1 Answers   Adobe,


write a program to produce the following output; ABCDEFGFEDCBA ABCDEF FEDCBA ABCDE EDCBA ABCD DCBA ABC CBA AB BA A A

17 Answers   ABC, College School Exams Tests,


helllo sir give me some information of the basic information the c as printf ,scanf , %d ,%f and why is the main use of these.

3 Answers  


#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??

1 Answers  


how to print the character with maximum occurence and print that number of occurence too in a string given ?

1 Answers   Microsoft,


What are the advantages of c preprocessor?

1 Answers  


Categories