1copysign(3)                Library Functions Manual                copysign(3)
2
3
4

NAME

6       copysign, copysignf, copysignl - copy sign of a number
7

LIBRARY

9       Math library (libm, -lm)
10

SYNOPSIS

12       #include <math.h>
13
14       double copysign(double x, double y);
15       float copysignf(float x, float y);
16       long double copysignl(long double x, long double y);
17
18   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
19
20       copysign(), copysignf(), copysignl():
21           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
22               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
23               || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
24

DESCRIPTION

26       These  functions return a value whose absolute value matches that of x,
27       but whose sign bit matches that of y.
28
29       For example, copysign(42.0, -1.0) and copysign(-42.0, -1.0) both return
30       -42.0.
31

RETURN VALUE

33       On  success,  these  functions  return a value whose magnitude is taken
34       from x and whose sign is taken from y.
35
36       If x is a NaN, a NaN with the sign bit of y is returned.
37

ERRORS

39       No errors occur.
40

ATTRIBUTES

42       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
43       tributes(7).
44
45       ┌────────────────────────────────────────────┬───────────────┬─────────┐
46Interface                                   Attribute     Value   
47       ├────────────────────────────────────────────┼───────────────┼─────────┤
48copysign(), copysignf(), copysignl()        │ Thread safety │ MT-Safe │
49       └────────────────────────────────────────────┴───────────────┴─────────┘
50

VERSIONS

52       On architectures where the floating-point formats are not IEEE 754 com‐
53       pliant, these functions may treat a negative zero as positive.
54

STANDARDS

56       C11, POSIX.1-2008.
57
58       This function is defined in IEC 559 (and the appendix with  recommended
59       functions in IEEE 754/IEEE 854).
60

HISTORY

62       C99, POSIX.1-2001, 4.3BSD.
63

SEE ALSO

65       signbit(3)
66
67
68
69Linux man-pages 6.04              2023-03-30                       copysign(3)
Impressum