gpt4 book ai didi

javascript ->> 在 JavaScript 中做什么?

转载 作者:行者123 更新时间:2023-12-02 16:21:01 28 4
gpt4 key购买 nike

在审查“Crossfilter”源代码时,我遇到了一个使用 >> 的函数。下面是函数:

  // Similar to bisectLeft, but returns an insertion point which comes after (to
// the right of) any existing entries of x in a.
//
// The returned insertion point i partitions the array into two halves so that
// all v <= x for v in a[lo:i] for the left side and all v > x for v in
// a[i:hi] for the right side.

function bisectRight(a, x, lo, hi) {
while (lo < hi) {
var mid = lo + hi >> 1;
if (x < f(a[mid])) hi = mid;
else lo = mid + 1;
}
return lo;
}

Google 没有返回任何结果,我以前从未见过这种情况。预先感谢您的帮助。

最佳答案

这是 sign-propagating right shift operator :

This operator shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Copies of the leftmost bit are shifted in from the left. Since the new leftmost bit has the same value as the previous leftmost bit, the sign bit (the leftmost bit) does not change. Hence the name "sign-propagating".

关于javascript ->> 在 JavaScript 中做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10932381/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com