Skip to content

Latest commit

 

History

History
84 lines (67 loc) · 2.77 KB

copysign-copysignf-copysignl-copysign-copysignf-copysignl.md

File metadata and controls

84 lines (67 loc) · 2.77 KB
title description ms.date api_name api_location api_type topic_type f1_keywords helpviewer_keywords ms.assetid
copysign, copysignf, copysignl, _copysign, _copysignf, _copysignl
API ref for returning a value that has the magnitude of one argument and the sign of another using copysign()
9/1/2020
copysignf
copysignl
_copysignl
_copysign
_copysignf
copysign
msvcrt.dll
msvcr80.dll
msvcr90.dll
msvcr100.dll
msvcr100_clr0400.dll
msvcr110.dll
msvcr110_clr0400.dll
msvcr120.dll
msvcr120_clr0400.dll
ucrtbase.dll
api-ms-win-crt-math-l1-1-0.dll
DLLExport
apiref
_copysignl
copysign
copysignf
_copysign
copysignl
_copysignf
copysignl function
_copysignl function
copysign function
_copysignf function
_copysign function
copysignf function
009216d6-72a2-402d-aa6c-91d924b2c9e4

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
);
#define copysign(X, Y) // Requires C11 or higher

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.

Math and floating-point support

Return value

The copysign functions return a floating-point value that combines the magnitude of x and the sign of y. There's 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, unless you're using the <tgmath.h> macro to call this function, copysign always takes and returns a double.

If you use the <tgmath.h> copysign() macro, the type of the argument determines which version of the function is selected. See Type-generic math for details.

Requirements

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

For more compatibility information, see Compatibility.

See also

fabs, fabsf, fabsl
_chgsign, _chgsignf, _chgsignl