We would like to divide an int value 32 to 16 without using arithmetic operator or function in Java.
And we cannot use * or + or Math.pow()
function.
public class Main { public static void main(String args[]) { int a = 32; System.out.println(a >> 1); System.out.println(a >> 2); } }
Each time you shift a value to the right, it divides that value by two and discards any remainder.
We can use this for high-performance integer division by 2.