1219820Sjeff/* $NetBSD: isnanl_ieee754.c,v 1.6 2011/01/17 23:53:03 matt Exp $ */ 2219820Sjeff 3219820Sjeff/* 4219820Sjeff * Copyright (c) 1992, 1993 5219820Sjeff * The Regents of the University of California. All rights reserved. 6219820Sjeff * 7219820Sjeff * This software was developed by the Computer Systems Engineering group 8219820Sjeff * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 9219820Sjeff * contributed to Berkeley. 10219820Sjeff * 11219820Sjeff * Redistribution and use in source and binary forms, with or without 12219820Sjeff * modification, are permitted provided that the following conditions 13219820Sjeff * are met: 14219820Sjeff * 1. Redistributions of source code must retain the above copyright 15219820Sjeff * notice, this list of conditions and the following disclaimer. 16219820Sjeff * 2. Redistributions in binary form must reproduce the above copyright 17219820Sjeff * notice, this list of conditions and the following disclaimer in the 18219820Sjeff * documentation and/or other materials provided with the distribution. 19219820Sjeff * 3. Neither the name of the University nor the names of its contributors 20219820Sjeff * may be used to endorse or promote products derived from this software 21219820Sjeff * without specific prior written permission. 22219820Sjeff * 23219820Sjeff * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24219820Sjeff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25219820Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26219820Sjeff * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27219820Sjeff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28219820Sjeff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29219820Sjeff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30219820Sjeff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31219820Sjeff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32219820Sjeff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33219820Sjeff * SUCH DAMAGE. 34219820Sjeff * 35219820Sjeff * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp 36219820Sjeff */ 37219820Sjeff 38219820Sjeff#include <sys/cdefs.h> 39219820Sjeff#if defined(LIBC_SCCS) && !defined(lint) 40219820Sjeff#if 0 41219820Sjeffstatic char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; 42219820Sjeff#else 43219820Sjeff__RCSID("$NetBSD: isnanl_ieee754.c,v 1.6 2011/01/17 23:53:03 matt Exp $"); 44219820Sjeff#endif 45219820Sjeff#endif /* LIBC_SCCS and not lint */ 46219820Sjeff 47219820Sjeff#include <machine/ieee.h> 48219820Sjeff#include <math.h> 49219820Sjeff 50219820Sjeff#ifdef __HAVE_LONG_DOUBLE 51219820Sjeff/* 52219820Sjeff * 7.12.3.4 isnan - test for a NaN 53219820Sjeff * IEEE 754 compatible 128-bit extended-precision version 54219820Sjeff */ 55219820Sjeffint 56219820Sjeff__isnanl(long double x) 57219820Sjeff{ 58219820Sjeff union ieee_ext_u u; 59219820Sjeff 60219820Sjeff u.extu_ld = x; 61219820Sjeff 62219820Sjeff return u.extu_ext.ext_exp == EXT_EXP_INFNAN 63219820Sjeff && (u.extu_ext.ext_frach != 0 64219820Sjeff#if EXT_FRACHMBITS 65219820Sjeff || u.extu_ext.ext_frachm != 0 66219820Sjeff#endif 67219820Sjeff#if EXT_FRACLMBITS 68219820Sjeff || u.extu_ext.ext_fraclm != 0 69219820Sjeff#endif 70219820Sjeff || u.extu_ext.ext_fracl != 0); 71219820Sjeff} 72219820Sjeff#endif /* __HAVE_LONG_DOUBLE */ 73219820Sjeff