Welcome to mirror list, hosted at ThFree Co, Russian Federation.

fp_consts.c « mingwex « mingw « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9293eeda468d705573fd098a75328fc63b5f6c9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* Floating point consts needed by STL class mumeric_limits<float>
 and  numeric_limits<double>.  Also used as return values by nan, inf */
  
#include <math.h>
/*
According to IEEE 754 a QNaN has exponent bits of all 1 values and
initial significand bit of 1.  A SNaN has has an exponent of all 1
values and initial significand bit of 0 (with one or more other
significand bits of 1). An Inf has significand of 0 and
exponent of all 1 values. A denormal value has all exponent bits of 0.

The following does _not_ follow those rules, but uses values
equal to those exported from MS C++ runtime lib, msvcprt.dll
for float and double. MSVC however, does not have long doubles.
*/


#define __DOUBLE_INF_REP { 0, 0, 0, 0x7ff0 }
#define __DOUBLE_QNAN_REP { 0, 0, 0, 0xfff8 }  /* { 0, 0, 0, 0x7ff8 }  */
#define __DOUBLE_SNAN_REP { 0, 0, 0, 0xfff0 }  /* { 1, 0, 0, 0x7ff0 }  */
#define __DOUBLE_DENORM_REP {1, 0, 0, 0}
#define D_NAN_MASK 0x7ff0000000000000LL /* this will mask NaN's and Inf's */

#define __FLOAT_INF_REP { 0, 0x7f80 }
#define __FLOAT_QNAN_REP { 0, 0xffc0 }  /* { 0, 0x7fc0 }  */
#define __FLOAT_SNAN_REP { 0, 0xff80 }  /* { 1, 0x7f80 }  */
#define __FLOAT_DENORM_REP {1,0}
#define F_NAN_MASK 0x7f800000

/* This assumes no implicit (hidden) bit in extended mode */
#define __LONG_DOUBLE_INF_REP { 0, 0, 0, 0x8000, 0x7fff }
#define __LONG_DOUBLE_QNAN_REP { 0, 0, 0, 0xc000, 0xffff } 
#define __LONG_DOUBLE_SNAN_REP { 0, 0, 0, 0x8000, 0xffff }
#define __LONG_DOUBLE_DENORM_REP {1, 0, 0, 0, 0}

union _ieee_rep
{
  unsigned short rep[5];
  float float_val;
  double double_val;
  long double ldouble_val;
} ;

const union _ieee_rep __QNAN = { __DOUBLE_QNAN_REP };
/*
const union _ieee_rep __SNAN = { __DOUBLE_SNAN_REP };
const union _ieee_rep __INF = { __DOUBLE_INF_REP };
const union _ieee_rep __DENORM = { __DOUBLE_DENORM_REP };
*/
/* ISO C99 */

#undef nan
/* FIXME */
double nan (const char * tagp __attribute__((unused)) )
	{ return __QNAN.double_val; } 


const union _ieee_rep __QNANF = { __FLOAT_QNAN_REP };   
/*
const union _ieee_rep __SNANF = { __FLOAT_SNAN_REP };   
const union _ieee_rep __INFF = { __FLOAT_INF_REP };   
const union _ieee_rep __DENORMF = { __FLOAT_DENORM_REP };   
*/

#undef nanf
/* FIXME */
float nanf(const char * tagp __attribute__((unused)) )
  { return __QNANF.float_val;}


const union _ieee_rep __QNANL = { __LONG_DOUBLE_QNAN_REP };
/*
const union _ieee_rep __SNANL = { __LONG_DOUBLE_SNAN_REP };
const union _ieee_rep __INFL = { __LONG_DOUBLE_INF_REP };
const union _ieee_rep __DENORML = { __LONG_DOUBLE_DENORM_REP };
*/

#undef nanl
/* FIXME */
long double nanl (const char * tagp __attribute__((unused)) )
  { return __QNANL.ldouble_val;}