]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de) |
1f985ccf MK |
2 | .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk |
3 | .\" <mtk.manpages@gmail.com> | |
2297bf0e | 4 | .\" |
95fb8859 | 5 | .\" SPDX-License-Identifier: GPL-1.0-or-later |
ce347053 | 6 | .\" |
7dcae896 | 7 | .\" Based on glibc infopages, copyright Free Software Foundation |
ce347053 | 8 | .\" |
1d767b55 | 9 | .TH SIGNBIT 3 2021-03-22 "GNU" "Linux Programmer's Manual" |
fea681da | 10 | .SH NAME |
1f985ccf | 11 | signbit \- test sign of a real floating-point number |
72328dd5 AC |
12 | .SH LIBRARY |
13 | Math library | |
8fc3b2cf | 14 | .RI ( libm ", " \-lm ) |
fea681da | 15 | .SH SYNOPSIS |
c7db92b9 | 16 | .nf |
fea681da | 17 | .B "#include <math.h>" |
68e4db0a | 18 | .PP |
fe93e677 | 19 | .BI "int signbit(" x ");" |
c7db92b9 | 20 | .fi |
68e4db0a | 21 | .PP |
d39ad78f | 22 | .RS -4 |
1f985ccf MK |
23 | Feature Test Macro Requirements for glibc (see |
24 | .BR feature_test_macros (7)): | |
d39ad78f | 25 | .RE |
68e4db0a | 26 | .PP |
1f985ccf | 27 | .BR signbit (): |
9d2adbae | 28 | .nf |
5c10d2c5 | 29 | _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
9d2adbae | 30 | .fi |
fea681da | 31 | .SH DESCRIPTION |
fe93e677 MK |
32 | .BR signbit () |
33 | is a generic macro which can work on all real floating-point types. | |
c7094399 | 34 | It returns a nonzero value if the value of |
fe93e677 MK |
35 | .I x |
36 | has its sign bit set. | |
fea681da | 37 | .PP |
9fb1e24a | 38 | This is not the same as |
fe93e677 | 39 | .IR "x < 0.0" , |
1f985ccf | 40 | because IEEE 754 floating point allows zero to be signed. |
9fb1e24a | 41 | The comparison |
1ae6b2c7 | 42 | .I \-0.0\~<\~0.0 |
9fb1e24a | 43 | is false, but |
1ae6b2c7 | 44 | .I signbit(\-0.0) |
c7094399 | 45 | will return a nonzero value. |
847e0d88 | 46 | .PP |
1f985ccf MK |
47 | NaNs and infinities have a sign bit. |
48 | .SH RETURN VALUE | |
49 | The | |
50 | .BR signbit () | |
c7094399 | 51 | macro returns nonzero if the sign of |
f6ecd76e | 52 | .I x |
1f985ccf MK |
53 | is negative; otherwise it returns zero. |
54 | .SH ERRORS | |
55 | No errors occur. | |
543840ca | 56 | .SH ATTRIBUTES |
5f1e440f PH |
57 | For an explanation of the terms used in this section, see |
58 | .BR attributes (7). | |
c466875e MK |
59 | .ad l |
60 | .nh | |
5f1e440f PH |
61 | .TS |
62 | allbox; | |
c466875e | 63 | lbx lb lb |
5f1e440f PH |
64 | l l l. |
65 | Interface Attribute Value | |
66 | T{ | |
543840ca | 67 | .BR signbit () |
5f1e440f PH |
68 | T} Thread safety MT-Safe |
69 | .TE | |
c466875e MK |
70 | .hy |
71 | .ad | |
72 | .sp 1 | |
47297adb | 73 | .SH CONFORMING TO |
267bb6ab | 74 | POSIX.1-2001, POSIX.1-2008, C99. |
c13182ef | 75 | This function is defined in IEC 559 (and the appendix with |
fea681da | 76 | recommended functions in IEEE 754/IEEE 854). |
47297adb | 77 | .SH SEE ALSO |
fea681da | 78 | .BR copysign (3) |