bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Math copySign() Method

❮ Math Methods

Example

System.out.println(Math.copySign(-4.7, 3));
System.out.println(Math.copySign(4.7, -2.5));
System.out.println(Math.copySign(3, 4));
System.out.println(Math.copySign(-2.5, -4.7));

Definition and Usage

The copySign() method returns the value of the first number with the sign of the second number.

One of the following

public static double copySign(double
value , double
sign )
public static float copySign(float
value , float
sign )

Parameter Values

ParameterDescription
valueRequired. A number which determines the value.
signRequired. A number which determines the sign.

Technical Details

Returns:A double or float with the value of the first number and the sign of the second number.
Java version:1.6+

Previous

Java Math ceil() Method

Next

Java Math cos() Method