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

前端 未结 23 1770
甜味超标
甜味超标 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条回答
  •  青春惊慌失措
    2020-11-27 09:50

    x = x / 2; is the suitable code to use.. but an operation depend on your own program of how the output you wanted to produce.

提交回复
热议问题