]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/signbit.3
03e74d47e54ec20a0f94453645a376a76d458141
[thirdparty/man-pages.git] / man3 / signbit.3
1 .\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
4 .\"
5 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
6 .\" Distributed under GPL
7 .\" %%%LICENSE_END
8 .\"
9 .\" Based on glibc infopages, copyright Free Software Foundation
10 .\"
11 .TH SIGNBIT 3 2015-08-08 "GNU" "Linux Programmer's Manual"
12 .SH NAME
13 signbit \- test sign of a real floating-point number
14 .SH SYNOPSIS
15 .B "#include <math.h>"
16 .sp
17 .BI "int signbit(" x ");"
18 .sp
19 Link with \fI\-lm\fP.
20 .sp
21 .in -4n
22 Feature Test Macro Requirements for glibc (see
23 .BR feature_test_macros (7)):
24 .in
25 .sp
26 .ad l
27 .BR signbit ():
28 .RS 4
29 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
30 _POSIX_C_SOURCE\ >=\ 200112L;
31 .br
32 or
33 .I cc\ -std=c99
34 .RE
35 .ad
36 .SH DESCRIPTION
37 .BR signbit ()
38 is a generic macro which can work on all real floating-point types.
39 It returns a nonzero value if the value of
40 .I x
41 has its sign bit set.
42 .PP
43 This is not the same as
44 .IR "x < 0.0" ,
45 because IEEE 754 floating point allows zero to be signed.
46 The comparison
47 .IR "-0.0 < 0.0"
48 is false, but
49 .IR "signbit(\-0.0)"
50 will return a nonzero value.
51
52 NaNs and infinities have a sign bit.
53 .SH RETURN VALUE
54 The
55 .BR signbit ()
56 macro returns nonzero if the sign of
57 .I x
58 is negative; otherwise it returns zero.
59 .SH ERRORS
60 No errors occur.
61 .SH ATTRIBUTES
62 For an explanation of the terms used in this section, see
63 .BR attributes (7).
64 .TS
65 allbox;
66 lb lb lb
67 l l l.
68 Interface Attribute Value
69 T{
70 .BR signbit ()
71 T} Thread safety MT-Safe
72 .TE
73 .SH CONFORMING TO
74 POSIX.1-2001, POSIX.1-2008, C99.
75 This function is defined in IEC 559 (and the appendix with
76 recommended functions in IEEE 754/IEEE 854).
77 .SH SEE ALSO
78 .BR copysign (3)