]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/copysign.3
5a24d5e1958fc2163f8a719a62f4f3e24e3d07c1
[thirdparty/man-pages.git] / man3 / copysign.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .\" References consulted:
6 .\" Linux libc source code
7 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
8 .\" 386BSD man pages
9 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
10 .\" Modified 2002-08-10 by Walter Harms (walter.harms@informatik.uni-oldenburg.de)
11 .TH COPYSIGN 3 2021-03-22 "Linux man-pages (unreleased)" "Linux Programmer's Manual"
12 .SH NAME
13 copysign, copysignf, copysignl \- copy sign of a number
14 .SH LIBRARY
15 Math library
16 .RI ( libm ", " \-lm )
17 .SH SYNOPSIS
18 .nf
19 .B #include <math.h>
20 .PP
21 .BI "double copysign(double " x ", double " y );
22 .BI "float copysignf(float " x ", float " y );
23 .BI "long double copysignl(long double " x ", long double " y );
24 .fi
25 .PP
26 .RS -4
27 Feature Test Macro Requirements for glibc (see
28 .BR feature_test_macros (7)):
29 .RE
30 .PP
31 .BR copysign (),
32 .BR copysignf (),
33 .BR copysignl ():
34 .nf
35 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
36 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
37 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
38 .fi
39 .SH DESCRIPTION
40 These functions return a value whose absolute value matches that of
41 .IR x ,
42 but whose sign bit matches that of
43 .IR y .
44 .PP
45 For example,
46 .I "copysign(42.0,\ \-1.0)"
47 and
48 .I "copysign(\-42.0, \-1.0)"
49 both return \-42.0.
50 .SH RETURN VALUE
51 On success, these functions return a value whose magnitude is taken from
52 .I x
53 and whose sign is taken from
54 .IR y .
55 .PP
56 If
57 .I x
58 is a NaN,
59 a NaN with the sign bit of
60 .I y
61 is returned.
62 .SH ERRORS
63 No errors occur.
64 .SH ATTRIBUTES
65 For an explanation of the terms used in this section, see
66 .BR attributes (7).
67 .ad l
68 .nh
69 .TS
70 allbox;
71 lbx lb lb
72 l l l.
73 Interface Attribute Value
74 T{
75 .BR copysign (),
76 .BR copysignf (),
77 .BR copysignl ()
78 T} Thread safety MT-Safe
79 .TE
80 .hy
81 .ad
82 .sp 1
83 .SH STANDARDS
84 C99, POSIX.1-2001, POSIX.1-2008.
85 .\" 4.3BSD.
86 This function is defined in IEC 559 (and the appendix with
87 recommended functions in IEEE 754/IEEE 854).
88 .SH NOTES
89 On architectures where the floating-point formats are not IEEE 754 compliant,
90 these
91 functions may treat a negative zero as positive.
92 .SH SEE ALSO
93 .BR signbit (3)