.
[glibc.git] / sysdeps / i386 / isinfl.c
blob056d756d583c5700ba2b96d0427071ef91f5faa6
1 /* Check `long double' for Infinity. i386 FPU version.
2 Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18 Cambridge, MA 02139, USA. */
20 #include <math.h>
21 #include "ieee754.h"
23 #undef __isinfl
24 #undef isinfl
27 /* Return 0 if VALUE is finite or NaN, +1 if it
28 is +Infinity, -1 if it is -Infinity. */
29 int
30 __isinfl (long double value)
32 union ieee854_long_double u;
34 u.d = value;
36 /* Intel's interpretation of the IEEE 854 standard defines Inf to
37 have the maximum possible exponent and the MSB of the mantissa
38 set. No further bit of the mantissa must be set. */
39 if ((u.ieee.exponent & 0x7fff) == 0x7fff &&
40 u.ieee.mantissa0 == 0x80000000 && u.ieee.mantissa1 == 0)
41 return u.ieee.negative ? -1 : 1;
43 return 0;
46 weak_alias (__isinfl, isinfl);