Math.copySign(double magnitude, double sign) has the following syntax.
public static double copySign(double magnitude, double sign)
In the following code shows how to use Math.copySign(double magnitude, double sign) method.
public class Main { /* w w w. jav a 2s. c o m*/ public static void main(String[] args) { double x = 125.9; double y = -0.4873; System.out.println(Math.copySign(x, y)); System.out.println(Math.copySign(y, x)); } }
The code above generates the following result.