Which is better option to use for dividing an integer number by 2?

前端 未结 23 1738
甜味超标
甜味超标 2020-11-27 09:10

Which of the following techniques is the best option for dividing an integer by 2 and why?

Technique 1:

x = x >> 1;

Technique

23条回答
  •  Happy的楠姐
    2020-11-27 09:31

    X/Y is a correct one...and " >> " shifting operator..if we want two divide a integer we can use (/) dividend operator. shift operator is used to shift the bits..

    x=x/2; x/=2; we can use like this..

提交回复
热议问题