s_isnan.c revision 8870
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
132116Sjkh#ifndef lint
148870Srgrimesstatic char rcsid[] = "$Id: s_isnan.c,v 1.1.1.1 1994/08/19 09:39:52 jkh Exp $";
152116Sjkh#endif
162116Sjkh
172116Sjkh/*
182116Sjkh * isnan(x) returns 1 is x is nan, else 0;
192116Sjkh * no branching!
202116Sjkh */
212116Sjkh
222116Sjkh#include "math.h"
232116Sjkh#include "math_private.h"
242116Sjkh
252116Sjkh#ifdef __STDC__
262116Sjkh	int isnan(double x)
272116Sjkh#else
282116Sjkh	int isnan(x)
292116Sjkh	double x;
302116Sjkh#endif
312116Sjkh{
322116Sjkh	int32_t hx,lx;
332116Sjkh	EXTRACT_WORDS(hx,lx,x);
342116Sjkh	hx &= 0x7fffffff;
358870Srgrimes	hx |= (u_int32_t)(lx|(-lx))>>31;
362116Sjkh	hx = 0x7ff00000 - hx;
372116Sjkh	return (int)((u_int32_t)(hx))>>31;
382116Sjkh}
39