source: trunk/sys/libm/s_finite.c @ 185

Last change on this file since 185 was 1, checked in by alain, 8 years ago

First import

File size: 799 bytes
Line 
1
2/* @(#)s_finite.c 5.1 93/09/24 */
3/*
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 *
7 * Developed at SunPro, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
10 * is preserved.
11 * ====================================================
12 */
13
14/*
15 * finite(x) returns 1 is x is finite, else 0;
16 * no branching!
17 */
18
19#include <libm/fdlibm.h>
20
21#ifdef __STDC__
22static const double one = 1.0;
23#else
24static double one = 1.0;
25#endif
26
27#ifdef __STDC__
28        int finite(double x)
29#else
30        int finite(x)
31        double x;
32#endif
33{
34        int n0,hx; 
35        n0 = ((*(int*)&one)>>29)^1;
36        hx = *(n0+(int*)&x);
37        return  (unsigned)((hx&0x7fffffff)-0x7ff00000)>>31;
38}
Note: See TracBrowser for help on using the repository browser.