Wednesday, 15 February 2017

Math : copysign



public class CopySign {

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

}

No comments:

Post a Comment