This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: floating point underflow; exception on attempt to print value less than DBL_MIN


>>>>> "Loren" == Loren James Rittle <rittle@latour.rsch.comm.mot.com> writes:

Loren> #include <float.h>
Loren> main() {
Loren>   double d = DBL_MIN;
Loren>   printf (" = %.17g;\n", d);
Loren>   printf (" = %.17g;\n", d/10);
Loren>   printf (" = %.17g;\n", (DBL_MIN/10)*10);
Loren>   printf (" = %.17g;\n", (DBL_MIN/10));
Loren> }

Loren> S rittle@clerc-milon; a.out
Loren>  = 2.2250738585072014e-308;
Loren>  = 0;
Loren>  = 2.2250738585072034e-308;
Loren> floating point exception--core dumped

Loren> make any sense?  Not to me.

I can't claim to understand it.  And I don't  know why the printf
would fail in the first place.  Perhaps the double->string conversion
function is incorrect in some way (that's just one theory of several).

glibc has feholdexcept(), from fenv.h, which might be useful.  Does
your platform have this?  The glibc manual talks about this in terms
of floating-point only; hopefully using this won't affect integer
divide-by-zero.  I guess if it does then your platform would need to
use the integer divide subroutine.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]