Android Renderscript rotateLeft

时间:2013-04-15 09:47:57

标签: android renderscript

如何实现此Java函数:

    public static int rotateLeft(int i, int distance) {
        // Shift distances are mod 32 (JLS3 15.19), so we needn't mask -distance
        return (i << distance) | (i >>> -distance);
    }

Renderscript

1 个答案:

答案 0 :(得分:1)

它与C相同,所以像

static int rotateLeft(int i, int distance) {
  return (i << (distance % 32)) | ((unsigned int)i >> (32 - (distance % 32)));
}