1174684Sdas/*-
2174684Sdas * Copyright (c) 2007 David Schultz
3174684Sdas * All rights reserved.
4174684Sdas *
5174684Sdas * Redistribution and use in source and binary forms, with or without
6174684Sdas * modification, are permitted provided that the following conditions
7174684Sdas * are met:
8174684Sdas * 1. Redistributions of source code must retain the above copyright
9174684Sdas *    notice, this list of conditions and the following disclaimer.
10174684Sdas * 2. Redistributions in binary form must reproduce the above copyright
11174684Sdas *    notice, this list of conditions and the following disclaimer in the
12174684Sdas *    documentation and/or other materials provided with the distribution.
13174684Sdas *
14174684Sdas * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15174684Sdas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16174684Sdas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17174684Sdas * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
18174684Sdas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19174684Sdas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20174684Sdas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21174684Sdas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22174684Sdas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23174684Sdas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24174684Sdas * SUCH DAMAGE.
25174684Sdas *
26174684Sdas * $FreeBSD$
27174684Sdas */
28174684Sdas
29174684Sdas#include <math.h>
30174684Sdas
31174684Sdas#include "fpmath.h"
32174759Sdas#include "../src/math_private.h"
33174684Sdas
34174684Sdaslong double
35174684Sdasnanl(const char *s)
36174684Sdas{
37174759Sdas	union {
38174759Sdas		union IEEEl2bits ieee;
39174759Sdas		uint32_t bits[3];
40174759Sdas	} u;
41174684Sdas
42174759Sdas	_scan_nan(u.bits, 3, s);
43174759Sdas	u.ieee.bits.exp = 0x7fff;
44174759Sdas	u.ieee.bits.manh |= 0xc0000000;	/* make it a quiet NaN */
45174759Sdas	return (u.ieee.e);
46174684Sdas}
47