You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns a value that has the magnitude of one argument and the sign of another.
Syntax
double copysign(
double x,
double y
);
float copysign(
float x,
float y
); // C++ only
long double copysign(
long double x,
long double y
); // C++ only
float copysignf(
float x,
float y
); // C++ only
long double copysignl(
long double x,
long double y
); // C++ only
double _copysign(
double x,
double y
);
long double _copysignl(
long double x,
long double y
);
Parameters
x
The floating-point value that's returned as the magnitude of the result.
y
The floating-point value that's returned as the sign of the result.
The copysign functions return a floating-point value that combines the magnitude of x and the sign of y. There is no error return.
Remarks
Because C++ allows overloading, you can call overloads of copysign that take and return float or long double values. In a C program, copysign always takes and returns a double.