Use free Windows DDK and compile with latest MinGW releases.
[reactos.git] / reactos / lib / msvcrt / float / fpclass.c
1 #include <msvcrti.h>
2
3
4 #define _FPCLASS_SNAN 0x0001 /* signaling NaN */
5 #define _FPCLASS_QNAN 0x0002 /* quiet NaN */
6 #define _FPCLASS_NINF 0x0004 /* negative infinity */
7 #define _FPCLASS_NN 0x0008 /* negative normal */
8 #define _FPCLASS_ND 0x0010 /* negative denormal */
9 #define _FPCLASS_NZ 0x0020 /* -0 */
10 #define _FPCLASS_PZ 0x0040 /* +0 */
11 #define _FPCLASS_PD 0x0080 /* positive denormal */
12 #define _FPCLASS_PN 0x0100 /* positive normal */
13 #define _FPCLASS_PINF 0x0200 /* positive infinity */
14
15 #define FP_SNAN 0x0001 // signaling NaN
16 #define FP_QNAN 0x0002 // quiet NaN
17 #define FP_NINF 0x0004 // negative infinity
18 #define FP_PINF 0x0200 // positive infinity
19 #define FP_NDENORM 0x0008 // negative denormalized non-zero
20 #define FP_PDENORM 0x0010 // positive denormalized non-zero
21 #define FP_NZERO 0x0020 // negative zero
22 #define FP_PZERO 0x0040 // positive zero
23 #define FP_NNORM 0x0080 // negative normalized non-zero
24 #define FP_PNORM 0x0100 // positive normalized non-zero
25
26 typedef int fpclass_t;
27
28 fpclass_t _fpclass(double __d)
29 {
30 double_t *d = (double_t *)&__d;
31
32 if ( d->exponent == 0 ) {
33 if ( d->mantissah == 0 && d->mantissal == 0 ) {
34 if ( d->sign ==0 )
35 return FP_NZERO;
36 else
37 return FP_PZERO;
38 } else {
39 if ( d->sign ==0 )
40 return FP_NDENORM;
41 else
42 return FP_PDENORM;
43 }
44 }
45 if (d->exponent == 0x7ff ) {
46 if ( d->mantissah == 0 && d->mantissal == 0 ) {
47 if ( d->sign ==0 )
48 return FP_NINF;
49 else
50 return FP_PINF;
51 }
52 else if ( d->mantissah == 0 && d->mantissal != 0 ) {
53 return FP_QNAN;
54 }
55 else if ( d->mantissah == 0 && d->mantissal != 0 ) {
56 return FP_SNAN;
57 }
58
59 }
60
61 return 0;
62 }
63
64