master
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#define __CRT__NO_INLINE
7#include <math.h>
8
9/* 'fxam' sets FPU flags C3,C2,C0 'fstsw' stores:
10 FP_NAN 001 0x0100
11 FP_NORMAL 010 0x0400
12 FP_INFINITE 011 0x0500
13 FP_ZERO 100 0x4000
14 FP_SUBNORMAL 110 0x4400
15
16and sets C1 flag (signbit) if neg */
17
18int __fpclassify (double _x)
19{
20 __mingw_dbl_type_t hlp;
21 unsigned int l, h;
22
23 hlp.x = _x;
24 h = hlp.lh.high;
25 l = hlp.lh.low | (h & 0xfffff);
26 h &= 0x7ff00000;
27 if ((h | l) == 0)
28 return FP_ZERO;
29 if (!h)
30 return FP_SUBNORMAL;
31 if (h == 0x7ff00000)
32 return (l ? FP_NAN : FP_INFINITE);
33 return FP_NORMAL;
34}