Java tutorial
public class Main { public static void main(String[] args) { float f1 = 3, f2 = -1, f3 = 1, f4 = -14; System.out.println("value of f1 with sign f2 : " + StrictMath.copySign(f1, f2)); System.out.println("value of f1 with sign f3 : " + StrictMath.copySign(f1, f3)); System.out.println("value of f2 with sign f4 : " + StrictMath.copySign(f2, f4)); } }