Java 中 x=-x 无效
int x=-2147483648; x=-x; System.out.print(x);
long 放的位置不一样就会出现不同的结果
@Test
public void test4() { int a = -2147483648; long x=-(long)a; long x1=(long)-a; System.out.print(x); //2147483648 System.out.print(x1); //-2147483648 }
int x=-2147483648; x=-x; System.out.print(x);
long 放的位置不一样就会出现不同的结果
@Test
public void test4() { int a = -2147483648; long x=-(long)a; long x1=(long)-a; System.out.print(x); //2147483648 System.out.print(x1); //-2147483648 }