1COPYSIGN(3) Linux Programmer's Manual COPYSIGN(3)
2
3
4
6 copysign, copysignf, copysignl - copy sign of a number
7
9 #include <math.h>
10
11 double copysign(double x, double y);
12 float copysignf(float x, float y);
13 long double copysignl(long double x, long double y);
14
15 Link with -lm.
16
17 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
18
19 copysign(), copysignf(), copysignl():
20 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
21 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
22 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
23
25 These functions return a value whose absolute value matches that of x,
26 but whose sign bit matches that of y.
27
28 For example, copysign(42.0, -1.0) and copysign(-42.0, -1.0) both return
29 -42.0.
30
32 On success, these functions return a value whose magnitude is taken
33 from x and whose sign is taken from y.
34
35 If x is a NaN, a NaN with the sign bit of y is returned.
36
38 No errors occur.
39
41 For an explanation of the terms used in this section, see
42 attributes(7).
43
44 ┌─────────────────────────────────────┬───────────────┬─────────┐
45 │Interface │ Attribute │ Value │
46 ├─────────────────────────────────────┼───────────────┼─────────┤
47 │copysign(), copysignf(), copysignl() │ Thread safety │ MT-Safe │
48 └─────────────────────────────────────┴───────────────┴─────────┘
50 C99, POSIX.1-2001, POSIX.1-2008. This function is defined in IEC 559
51 (and the appendix with recommended functions in IEEE 754/IEEE 854).
52
54 On architectures where the floating-point formats are not IEEE 754 com‐
55 pliant, these functions may treat a negative zero as positive.
56
58 signbit(3)
59
61 This page is part of release 5.04 of the Linux man-pages project. A
62 description of the project, information about reporting bugs, and the
63 latest version of this page, can be found at
64 https://www.kernel.org/doc/man-pages/.
65
66
67
68GNU 2017-09-15 COPYSIGN(3)