简体   繁体   中英

Android Renderscript rotateLeft

How do I implement this Java function:

    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);
    }

In Renderscript ?

It's the same as C, so something like

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM