source: trunk/libs/newlib/src/newlib/libm/common/s_signbit.c @ 471

Last change on this file since 471 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.3 KB
Line 
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/*
7FUNCTION
8<<signbit>>---Does floating-point number have negative sign?
9
10INDEX
11        signbit
12
13SYNOPSIS
14        #include <math.h>
15        int signbit(real-floating <[x]>);
16
17DESCRIPTION
18The <<signbit>> macro determines whether the sign of its argument value is
19negative.  The macro reports the sign of all values, including infinities,
20zeros, and NaNs.  If zero is unsigned, it is treated as positive.  As shown in
21the synopsis, the argument is "real-floating," meaning that any of the real
22floating-point types (float, double, etc.) may be given to it.
23
24Note 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
27RETURNS
28The <<signbit>> macro returns a nonzero value if and only if the sign of its
29argument value is negative.
30
31PORTABILITY
32C99, POSIX.
33
34*/
35
36#include "fdlibm.h"
37
38int __signbitf (float x);
39int __signbitd (double x);
40
41int
42__signbitf (float x)
43{
44  __uint32_t w;
45
46  GET_FLOAT_WORD(w,x);
47
48  return (w & 0x80000000) != 0;
49}
50
51int
52__signbitd (double x)
53{
54  __uint32_t msw;
55
56  GET_HIGH_WORD(msw, x);
57
58  return (msw & 0x80000000) != 0;
59}
Note: See TracBrowser for help on using the repository browser.