How to do a logical right shift of negative numbers in C? I am mainly looking for the equivalent of C >>> in java
i.e.
int one = -16711936 ; //int two = -16711936 ; //int three = -1; int r, g, b; System.out.println(Integer.toBinaryString(one)); r = one << 8; r >>>= 24; g = one << 16; g >>>= 24; //this always ends up being -1 in C, instead of 255 b = one << 24; b >>>= 24;
source share