---------------- Begin Forwarded Message ---------------- Subject: Re: Quadratic and cubic equations Date Sent: Thursday, January 8, 2004 12:18 PM From: Brian Gough <[EMAIL PROTECTED]> To: Sascha Brawer <[EMAIL PROTECTED]> CC: Mark Wielaard <[EMAIL PROTECTED]>, Michael Koch <[EMAIL PROTECTED]>
Sascha Brawer writes: > I suspect that the problem is the test for (disc == 0) in gsl/poly/ > solve_quadratic.c, line 61. With the Java version of your code, we get a > very small negative number in gcj (the Java front-end for the GCC) on IA- > 32, and exactly 0.0 with some other Java Virtual Machines. The coefficient 0.1 does not have an exact representation in binary, so the number used will depend on the precision and the rounding mode. This will cause different results. I suspect that GCJ on Intel uses the 80-bit extended-precision floating point registers (which are the gcc default, in C also) while the other virtual machines probably use strict double-precision. I don't know much about GCJ but I'm sure the developers are aware of the issue, so there may be an option to control it. > Could it be that the test for (disc == 0) should actually be replaced by > something like (fabs(disc - 0.0) < EPSILON)? If so, which value is > appropriate for EPSILON? The best value is 0, as there is no natural choice for epsilon (it introduces an arbitrary constant). My recommendation: choose test coefficients which are exact in binary (e.g. in this case multiply the polynomial by 5) to avoid the problem. regards, -- Brian Gough Network Theory Ltd -- Publishing Free Software Manuals 15 Royal Park Bristol BS8 3AL United Kingdom Tel: +44 (0)117 3179309 Fax: +44 (0)117 9048108 Web: http://www.network-theory.co.uk/ ----------------- End Forwarded Message ----------------- _______________________________________________ Classpath mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/classpath

