Home
Calculator
Algebra
Fun Games
Geometry
Interactive
Trigonometry
Good Links
Home
Calculator
Algebra
Fun Games
Geometry
Interactive
Trigonometry
Good Links

A quirk of changing sign?

Java Changing Sign Arithmetic

1) To change the sign of a number you could ran simple Java program such as the one below:

This sign change wil work!

	public static  void main(String[] args) {
		int lowestInt = -2147483647;
		System.out.println("lowestInt "+ lowestInt);
		int oppositeOfLowestInt = lowestInt/-1;
		System.out.println("oppositeOfLowestInt  "+ oppositeOfLowestInt);
	}
	
	

However, change the value of our lowestInt by one and you will get a suprising result. If you run the function below, you will find the the oppositeOfLowestInt has not changed and evaluates to = -2147483648.
	public static  void main(String[] args) {
		int lowestInt = -2147483648;
		System.out.println("lowestInt "+ lowestInt);
		int oppositeOfLowestInt = lowestInt/-1;
		System.out.println("oppositeOfLowestInt  "+ oppositeOfLowestInt);
	}