found 560026 2.2.02+dfsg-6 notfound 560026 2.1.05 2.1.05+dfsg+cvs20091202-1 # these versions are over; I think, nobody wants to patch them anymore tags 560026 - help tags 560026 + patch thanks
The problem is in the source code file yorick/std0.c, line 1355, in the function expLoop():
static void expLoop(double *dst, double *src, long n) { long i; for (i=0 ; i<n ; i++) { dst[i]= exp(src[i]); if (errno) { if (errno==ERANGE && !dst[i]) errno=0; else break; } } }The function calculates the mathematical exp function for each item of the src array. One item is -744.668 (IEEE754 representation C08745590D710CC1) when the test runs. The exp() function sets errno to 34 (ERANGE) upon that and returns the IEEE754 representation 0000000000000001. This is around 4.94066E-324, a denormalized value; means underflow.
As you see above, the idea of the expLoop() code is to commute a result to 0 if exp() returns an underflow upon (large) negative exponents.
Unfortunately it doesn't work for the example since the check for a result of 0 - the
!dst[i] evaluates to 0 (false).Since errno isn't 0 after that, the yorick interpreter stops the execution of the script and reports the seen error message:
ERROR (escout) mathlib function signals error LINE: 251 FILE: /usr/lib/yorick/i/test2.i yorick: quitting on error in batch modeObviously the floating point arithmetic doesn't behave in the same way on the different archs in 'subnormal' cases. I assume, the exp() function returns denormalized values on ia64 but round them down to 0 on other archs.
My proposal is to the check the arg of exp() rather than the result in order to determine whether it is an underflow or not:
(Note that the pointer dst may be equal to the src pointer.) static void expLoop(double *dst, double *src, long n) { long i; for (i=0 ; i<n ; i++) { double e = src[i]; dst[i]= exp(e); if (errno) { if (errno==ERANGE && e<0.0) errno=0; else break; } } } The test does no longer fail, and can be enabled on ia64. Stephan
fix-exp-underflow.patch
Description: fix-exp-underflow.patch
enable-test-on-ia64.patch
Description: enable-test-on-ia64.patch