다음을 통해 공유


copysign, copysignf, copysignl, _copysign, _copysignf, _copysignl

 

The latest version of this topic can be found at copysign, copysignf, copysignl, _copysign, _copysignf, _copysignl.

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.

Floating-Point Support Routines

Return Value

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.

Requirements

Routine Required header
_copysign <float.h>
copysign, copysignf, copysignl, _copysignf``_copysignl <math.h>

For more compatibility information, see Compatibility.

.NET Framework Equivalent

Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.

See Also

fabs, fabsf, fabsl
_chgsign, _chgsignf, _chgsignl