On Wed, 23 Dec 2009, Tamas TEVESZ wrote: Hi,
> ok, so there are two places where this is used, in src/rtl/math.c:334 > onwards and src/vm/itemapi.c:2250 onwards. Three. src/common/hbprintf.c also includes it. Here is the only one place when we try to use different C99 FL functions not only finite() and we can use as argument 'long double' values not only double ones. It means that if possible we should not force arguments conversion to double because on some hardware or (and) when some fast math optimization switches are enabled it may cause SIGFPE if argument is not valid FL number. Harbour itself does not use any NaN values so it's not a problem for valid code but in some wrong user code it may cause detecting the source of problem harder. > they are even used for the same purpose, to check whether or not to > signal a range error of sorts on a numeric argument. In itemapi.c we only try to detect finite double values. In math.c when HB_MATH_ERRNO is set we try to detect also NaN values and we should cleaned this code because now it's possible that it will not work with compilers not supporting C++ isnan()/isinf() macros. In hb_snprintf() we additionally try to detect type of infinity and sign bit. I agree that it will be nice to use common macros set in all three files defined in some separate header file, i.e. hbfloat.h which will make all platform dependent #includes and define some HB_*() macros which we can use in other code. > yet the one in itemapi.c is a macro with a screenful of tests for > platforms and compilers and whatnot, whereas the one in math.c is a > very simple conditional for os2-sunos-all-the-rest. notably, it > doesn't have a special case for os/2 -- nb i do not know if > "defined( __RSXNT__ ) || defined( __EMX__ )" covers _all_ of os2; if > it does, then scratch this last remark, but then the notation is > inconstent. > why is this difference? The code in math.c was enabled only in some GCC builds so this trivial condition was working but in fact it's wrong and should be updated to use more precise logic. In some spare time I'll check if I can easy create hbfloat.h file which can be easy used also with hbprintf.c and if yest then I'll commit it. best regards, Przemek _______________________________________________ Harbour mailing list (attachment size limit: 40KB) Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour