Java examples for Language Basics:Math
Use the Math.abs and Math.signnum methods to force the sign of one variable to match the sign of another
public class Main { public static void main(String[] args) { int a = 27;//from w ww . j av a2s.c o m int b = -32; float f = Math.abs(a) * Math.signum(b); // a is now -27; System.out.println(f); } }