12fe8fb19SBen Gras /* @(#)s_finite.c 5.1 93/09/24 */
22fe8fb19SBen Gras /*
32fe8fb19SBen Gras * ====================================================
42fe8fb19SBen Gras * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
52fe8fb19SBen Gras *
62fe8fb19SBen Gras * Developed at SunPro, a Sun Microsystems, Inc. business.
72fe8fb19SBen Gras * Permission to use, copy, modify, and distribute this
82fe8fb19SBen Gras * software is freely granted, provided that this notice
92fe8fb19SBen Gras * is preserved.
102fe8fb19SBen Gras * ====================================================
112fe8fb19SBen Gras */
122fe8fb19SBen Gras
132fe8fb19SBen Gras #include <sys/cdefs.h>
142fe8fb19SBen Gras #if defined(LIBM_SCCS) && !defined(lint)
15*84d9c625SLionel Sambuc __RCSID("$NetBSD: s_finite.c,v 1.12 2013/11/12 17:37:43 joerg Exp $");
162fe8fb19SBen Gras #endif
172fe8fb19SBen Gras
182fe8fb19SBen Gras /*
19*84d9c625SLionel Sambuc * finite(x) returns 1 if x is finite, else 0;
202fe8fb19SBen Gras * no branching!
212fe8fb19SBen Gras */
222fe8fb19SBen Gras
232fe8fb19SBen Gras #include "math.h"
242fe8fb19SBen Gras #include "math_private.h"
252fe8fb19SBen Gras
262fe8fb19SBen Gras int
finite(double x)272fe8fb19SBen Gras finite(double x)
282fe8fb19SBen Gras {
292fe8fb19SBen Gras int32_t hx;
302fe8fb19SBen Gras GET_HIGH_WORD(hx,x);
312fe8fb19SBen Gras return (int)((u_int32_t)((hx&0x7fffffff)-0x7ff00000)>>31);
322fe8fb19SBen Gras }
33