2

I tried to multiply a negative value by -1 but I'm getting the same negative value itself:

long longValue = Long.MAX_VALUE;
int i = (int) (longValue ^ (longValue >>> 32));
int a = i * -1;
//prints -2147483648
System.out.println(i);

//prints -2147483648
System.out.println(a);

In the above code both i and a print a negative value. Why is a not assigned a positive value?

RRadley
  • 333
  • 3
  • 7

0 Answers0