Java math copySign() is an inbuilt method that copies the sign of the second argument to the magnitude of the first argument and returns the result. As per the definition given by Oracle, this method has implementations permitted, which treats some NaN arguments as positive and other NaN arguments as negative to allow the greater performance.

Java Math copySign()

The java.lang.Math.copySign() method returns a first argument with the sign of the second argument.

Syntax

public static float copySign(float a, float b)
public static double copySign(double a, double b)

#java #java math copysign()

Java Math copySign() Function Example
1.20 GEEK