1131852Sdas/*-
2131852Sdas * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
3131852Sdas * All rights reserved.
4131852Sdas *
5131852Sdas * Redistribution and use in source and binary forms, with or without
6131852Sdas * modification, are permitted provided that the following conditions
7131852Sdas * are met:
8131852Sdas * 1. Redistributions of source code must retain the above copyright
9131852Sdas *    notice, this list of conditions and the following disclaimer.
10131852Sdas * 2. Redistributions in binary form must reproduce the above copyright
11131852Sdas *    notice, this list of conditions and the following disclaimer in the
12131852Sdas *    documentation and/or other materials provided with the distribution.
13131852Sdas *
14131852Sdas * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15131852Sdas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16131852Sdas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17131852Sdas * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18131852Sdas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19131852Sdas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20131852Sdas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21131852Sdas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22131852Sdas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23131852Sdas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24131852Sdas * SUCH DAMAGE.
25131852Sdas *
26131852Sdas * $FreeBSD$
27131852Sdas */
28131852Sdas
29131852Sdas#include <math.h>
30131852Sdas
31131852Sdas#include "fpmath.h"
32131852Sdas
33131852Sdas/*
34131852Sdas * XXX These routines belong in libm, but they must remain in libc for
35131852Sdas *     binary compat until we can bump libm's major version number.
36131852Sdas */
37131852Sdas
38131852Sdas__weak_reference(__isinf, isinf);
39131852Sdas
40131852Sdasint
41131852Sdas__isinf(double d)
42131852Sdas{
43131852Sdas	union IEEEd2bits u;
44131852Sdas
45131852Sdas	u.d = d;
46131852Sdas	return (u.bits.exp == 2047 && u.bits.manl == 0 && u.bits.manh == 0);
47131852Sdas}
48131852Sdas
49131852Sdasint
50131852Sdas__isinff(float f)
51131852Sdas{
52131852Sdas	union IEEEf2bits u;
53131852Sdas
54131852Sdas	u.f = f;
55131852Sdas	return (u.bits.exp == 255 && u.bits.man == 0);
56131852Sdas}
57131852Sdas
58131852Sdasint
59131852Sdas__isinfl(long double e)
60131852Sdas{
61131852Sdas	union IEEEl2bits u;
62131852Sdas
63131852Sdas	u.e = e;
64131852Sdas	mask_nbit_l(u);
65131898Smarcel#ifndef __alpha__
66131852Sdas	return (u.bits.exp == 32767 && u.bits.manl == 0 && u.bits.manh == 0);
67131898Smarcel#else
68131898Smarcel	return (u.bits.exp == 2047 && u.bits.manl == 0 && u.bits.manh == 0);
69131898Smarcel#endif
70131852Sdas}
71