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