What is >>> operation in C++

前端 未结 6 1090
半阙折子戏
半阙折子戏 2021-01-12 06:48

In this blog post the author has suggested the following as the bug fix:

 int mid = (low + high) >>> 1;

Does anyone know what is t

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-12 07:01

    It is a java operator, not related to C++.

    However all the blog author does is change the division by 2 with a bit-wise right shift (i.e. right shifting the value by 1 is similar to dividing by 2 ^ 1).

    Same functionality, different machine code output (bit shifting operations are almost always faster than multiplication/division on most architectures).

提交回复
热议问题