Hi all, A question from a mock exam: What happens when we attempt to compile and run the follwoing code? public class Logic{ static int minusOne=-1; static public void main(String args[]){ int N=minusOne >> 31; System.out.println("N ="+N);
Hi, As Zaal has correctly pointed out ,>> is signed rigth shift operator and -1>>31 results in -1 , but not 1. when >> is applied on a number, the sign bit of the no is always preserved and the result will have the same sign as tht of the original number. Vineela.
It will give me the powers of the gods. Not bad for a tiny ad:
a bit of art, as a gift, that will fit in a stocking