java.lang.Math.copySign(double magnitude, double sign)


java.lang.Math.copySign(double magnitude, double sign)

package com.codingdict;



import java.lang.*;



public class MathDemo {



   public static void main(String[] args) {



      // get two double numbers

      double x = 125.9;

      double y = -0.4873;



      // print a double with the magnitude of x and the sign of y

      System.out.println("Math.copySign(" + x + "," + y + ")=" + Math.copySign(x, y));



      // print a double with the magnitude of y and the sign of x

      System.out.println("Math.copySign(" + y + "," + x + ")=" + Math.copySign(y, x));

   }

}