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


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

package com.codingdict;



import java.lang.*;



public class MathDemo {



   public static void main(String[] args) {



      // get two float numbers

      float x = 125.9f;

      float y = -0.4873f;



      // 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));

   }

}