mathcopysign Method (Single, Single) |
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 float copysign(
float number1,
float number2
)
Public Shared Function copysign (
number1 As Single,
number2 As Single
) As Single
public:
static float copysign(
float number1,
float number2
)
static member copysign :
number1 : float32 *
number2 : float32 -> float32
Parameters
- number1
- Type: SystemSingle
A floating-point number. - number2
- Type: SystemSingle
A floating-point number.
Return Value
Type:
SingleThe floating-point number whose absolute value is that of
number1 with the sign of
number2.
Remarkscopysign(Single, Single) is the only portable way to manipulate the sign of a NaN value (to examine
the sign of a NaN, signbit(Single) may also be used).
See copysign in the C standard documentation.
ExamplesAssert.IsTrue(math.copysign(0F, -0F) == -0F);
Assert.IsTrue(math.copysign(0F, -4F) == -0F);
Assert.IsTrue(math.copysign(2F, -0F) == -2F);
Assert.IsTrue(math.copysign(-2F, 0F) == 2F);
Assert.IsTrue(math.copysign(System.Single.PositiveInfinity, -2F) == System.Single.NegativeInfinity);
Assert.IsTrue(math.copysign(2F, System.Single.NegativeInfinity) == -2F);
Assert.IsTrue(math.copysign(0F, -0F) = -0F);
Assert.IsTrue(math.copysign(0F, -4F) = -0F);
Assert.IsTrue(math.copysign(2F, -0F) = -2F);
Assert.IsTrue(math.copysign(-2F, 0F) = 2F);
Assert.IsTrue(math.copysign(System.Single.PositiveInfinity, -2F) = System.Single.NegativeInfinity);
Assert.IsTrue(math.copysign(2F, System.Single.NegativeInfinity) = -2F);
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