From: Earnie Boyd <earnie_boyd@ya...>  20020227 12:00:45

How about both with a macro (say _GCC_NAN) to switch the definition from the default of the MS definitions? That way we don't have to decide what the user wants. As for which header, where does MS say they belong? That would be my choice for the definitions and you could protect the exposure to only _cplusplus if that's a real concern. Earnie. Danny Smith wrote: > > Currently GCC 3.1 stl class numeric_limits<> for float and double lack > support for members infinity(), quiet_NaN(), signalling_NaN() and > denorm_min(), returning an arbitrary 0.0 for each. > > I have used the values that MS exports in msvcp60.dll (_Inf, _Nan, SNan, > _Denorm and _F* equiv.), as values for mingw implementation. > Appended code produces: > > nan= 1.#IND00 > nanf= 1.#IND00 > snan= 1.#INF00 > snanf= 1.#INF00 > inf= 1.#INF00 > inff= 1.#INF00 > denorm_min= 4.940656e324 > denorm_minf= 1.401298e045 > > Now I know that the printf'ing of the constants is not portable, and I know > that other x86 platforms use different constants to represent nan's. > Should I stick with the MSconsistent constants or should I use constants > consistent with glibc or newlib? The trouble with those is that printf'ing > with MS printf outputs 1.#QNAN00 for both quiet and signalling nans. > > Secondly, should I put the global constants and access functions in a > mingwextra lib (tentatively, there in libisocext.a) There not ansi, but > they are needed to support std C++. The C99 version of nan takes an > argument like so: > double nan(char* flagp) > but that can be fixed with an ARGS_UNUSED > > Should they be exposed in math.h header? > > They could go instead only into libstdc++.a and and put into a namespace > that hides them from C code. > > Here is the code: > > /* test_nan.c */ > > #define __FLOAT_INF_REP { 0, 0x7f80 } > #define __FLOAT_QNAN_REP { 0, 0xffc0 } > #define __FLOAT_SNAN_REP { 0, 0xff80 } > #define __FLOAT_DENORM_REP {1,0} > > #define __DOUBLE_INF_REP { 0, 0, 0, 0x7ff0 } > #define __DOUBLE_QNAN_REP { 0, 0, 0, 0xfff8 } > #define __DOUBLE_SNAN_REP { 0, 0, 0, 0xfff0 } > #define __DOUBLE_DENORM_REP {1,0,0,0} > > union _ieee_rep > { > unsigned short rep[4] /* should this be [5] for 80bit LD ? */; > float float_val; > double double_val; > } ; > > const union _ieee_rep __QNAN = { __DOUBLE_QNAN_REP }; > const union _ieee_rep __QNANF = { __FLOAT_QNAN_REP }; > const union _ieee_rep __SNAN = { __DOUBLE_SNAN_REP }; > const union _ieee_rep __SNANF = { __FLOAT_SNAN_REP }; > const union _ieee_rep __INF = { __DOUBLE_INF_REP }; > const union _ieee_rep __INFF = { __FLOAT_INF_REP }; > const union _ieee_rep __DENORM = { __DOUBLE_DENORM_REP }; > const union _ieee_rep __DENORMF = { __FLOAT_DENORM_REP }; > > double _nan () > { > return __QNAN.double_val; > } > > float _nanf () > { > return __QNANF.float_val; > } > > double _snan () > { > return __SNAN.double_val; > } > > float _snanf () > { > return __SNANF.float_val; > } > > double _inf () > { > return __INF.double_val; > } > > float _inff () > { > return __INFF.float_val; > } > > double _denorm_min () > { > return __DENORM.double_val; > } > > float _denorm_minf () > { > return __DENORMF.float_val; > } > > #include <stdio.h> > > int main(){ > printf("nan= %f\n", _nan()); > printf("nanf= %f\n", _nanf()); > printf("snan= %f\n", _snan()); > printf("snanf= %f\n", _snanf()); > printf("inf= %f\n", _inf()); > printf("inff= %f\n", _inff()); > printf("denorm_min= %e\n", _denorm_min()); > printf("denorm_minf= %e\n", _denorm_minf()); > return 0; > } > > http://movies.yahoo.com.au  Yahoo! Movies >  Vote for your nominees in our online Oscars pool. > > _______________________________________________ > MinGWdvlpr mailing list > MinGWdvlpr@... > https://lists.sourceforge.net/lists/listinfo/mingwdvlpr _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com 