Example usage for java.lang StrictMath copySign

List of usage examples for java.lang StrictMath copySign

Introduction

In this page you can find the example usage for java.lang StrictMath copySign.

Prototype

public static float copySign(float magnitude, float sign) 

Source Link

Document

Returns the first floating-point argument with the sign of the second floating-point argument.

Usage

From source file:Main.java

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

From source file:Main.java

public static void main(String[] args) {

    double d1 = 1.2, d2 = -1.2, d3 = 1.3, d4 = -14;

    System.out.println("value of d1 with sign d2 : " + StrictMath.copySign(d1, d2));

    System.out.println("value of d1 with sign d3 : " + StrictMath.copySign(d1, d3));

    System.out.println("value of d2 with sign d4 : " + StrictMath.copySign(d2, d4));
}