mathcopysign Method (Double, Double) |
Copies the sign of number2 to number1.
Namespace:
C
Assembly:
C.math (in C.math.dll) Version: 1.0.0.0 (1.0.0.0)
Syntaxpublic static double copysign(
double number1,
double number2
)
Public Shared Function copysign (
number1 As Double,
number2 As Double
) As Double
public:
static double copysign(
double number1,
double number2
)
static member copysign :
number1 : float *
number2 : float -> float
Parameters
- number1
- Type: SystemDouble
A floating-point number. - number2
- Type: SystemDouble
A floating-point number.
Return Value
Type:
DoubleThe floating-point number whose absolute value is that of
number1 with the sign of
number2.
Remarkscopysign(Double, Double) is the only portable way to manipulate the sign of a NaN value (to examine
the sign of a NaN, signbit(Double) may also be used).
See copysign in the C standard documentation.
ExamplesAssert.IsTrue(math.copysign(0D, -0D) == -0D);
Assert.IsTrue(math.copysign(0D, -4D) == -0D);
Assert.IsTrue(math.copysign(2D, -0D) == -2D);
Assert.IsTrue(math.copysign(-2D, 0D) == 2D);
Assert.IsTrue(math.copysign(System.Double.PositiveInfinity, -2D) == System.Double.NegativeInfinity);
Assert.IsTrue(math.copysign(2D, System.Double.NegativeInfinity) == -2D);
Assert.IsTrue(math.copysign(0D, -0D) = -0D);
Assert.IsTrue(math.copysign(0D, -4D) = -0D);
Assert.IsTrue(math.copysign(2D, -0D) = -2D);
Assert.IsTrue(math.copysign(-2D, 0D) = 2D);
Assert.IsTrue(math.copysign(System.Double.PositiveInfinity, -2D) = System.Double.NegativeInfinity);
Assert.IsTrue(math.copysign(2D, System.Double.NegativeInfinity) = -2D);
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also