1 /* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
2 *
3 * Permission to use, copy, modify, and distribute this software
4 * is freely granted, provided that this notice is preserved.
5 */
6 /*
7 FUNCTION
8 <<signbit>>---Does floating-point number have negative sign?
9
10 INDEX
11 signbit
12
13 SYNOPSIS
14 #include <math.h>
15 int signbit(real-floating <[x]>);
16
17 DESCRIPTION
18 The <<signbit>> macro determines whether the sign of its argument value is
19 negative. The macro reports the sign of all values, including infinities,
20 zeros, and NaNs. If zero is unsigned, it is treated as positive. As shown in
21 the synopsis, the argument is "real-floating," meaning that any of the real
22 floating-point types (float, double, etc.) may be given to it.
23
24 Note that because of the possibilities of signed 0 and NaNs, the expression
25 "<[x]> < 0.0" does not give the same result as <<signbit>> in all cases.
26
27 RETURNS
28 The <<signbit>> macro returns a nonzero value if and only if the sign of its
29 argument value is negative.
30
31 PORTABILITY
32 C99, POSIX.
33
34 */
35
36 #define _ADD_D_TO_DOUBLE_FUNCS
37
38 #include "fdlibm.h"
39
40 int
__signbitf(float x)41 __signbitf (float x)
42 {
43 __uint32_t w;
44
45 GET_FLOAT_WORD(w,x);
46
47 return (w & 0x80000000) != 0;
48 }
49
_MATH_ALIAS_i_f(__signbit)50 _MATH_ALIAS_i_f(__signbit)
51
52 #ifdef _NEED_FLOAT64
53 int
54 __signbit64(__float64 x)
55 {
56 __uint32_t msw;
57
58 GET_HIGH_WORD(msw, x);
59
60 return (msw & 0x80000000) != 0;
61 }
62
63 _MATH_ALIAS_i_d(__signbit)
64 #endif
65