s_isnan.c revision 110769
12116Sjkh/* @(#)s_isnan.c 5.1 93/09/24 */
22116Sjkh/*
32116Sjkh * ====================================================
42116Sjkh * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
52116Sjkh *
62116Sjkh * Developed at SunPro, a Sun Microsystems, Inc. business.
72116Sjkh * Permission to use, copy, modify, and distribute this
88870Srgrimes * software is freely granted, provided that this notice
92116Sjkh * is preserved.
102116Sjkh * ====================================================
112116Sjkh */
122116Sjkh
13110769Smike/* For binary compat; to be removed in FreeBSD 6.0. */
14110769Smike
152116Sjkh#ifndef lint
1650476Speterstatic char rcsid[] = "$FreeBSD: head/lib/msun/src/s_isnan.c 110769 2003-02-12 20:03:41Z mike $";
172116Sjkh#endif
182116Sjkh
192116Sjkh/*
202116Sjkh * isnan(x) returns 1 is x is nan, else 0;
212116Sjkh * no branching!
222116Sjkh */
232116Sjkh
242116Sjkh#include "math.h"
252116Sjkh#include "math_private.h"
262116Sjkh
27110769Smike#undef isnan
28110769Smike
292116Sjkh	int isnan(double x)
302116Sjkh{
312116Sjkh	int32_t hx,lx;
322116Sjkh	EXTRACT_WORDS(hx,lx,x);
332116Sjkh	hx &= 0x7fffffff;
348870Srgrimes	hx |= (u_int32_t)(lx|(-lx))>>31;
352116Sjkh	hx = 0x7ff00000 - hx;
362116Sjkh	return (int)((u_int32_t)(hx))>>31;
372116Sjkh}
38