From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA32050; Mon, 17 Jun 2002 16:06:02 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA32105 for caml-list@pauillac.inria.fr; Mon, 17 Jun 2002 16:06:01 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA30147; Mon, 17 Jun 2002 14:48:11 +0200 (MET DST) Date: Mon, 17 Jun 2002 14:48:11 +0200 From: Xavier Leroy To: Michael Vanier Cc: gaurav_chanda@lycos.com, caml-list@pauillac.inria.fr Subject: Re: [Caml-list] Catching exceptions into strings Message-ID: <20020617144811.B29486@pauillac.inria.fr> References: <200206102157.g5ALvZg04810@orchestra.cs.caltech.edu> <20020612105308.B29875@pauillac.inria.fr> <200206120936.g5C9asB18950@orchestra.cs.caltech.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <200206120936.g5C9asB18950@orchestra.cs.caltech.edu>; from mvanier@cs.caltech.edu on Wed, Jun 12, 2002 at 02:36:54AM -0700 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Thanks for the clear explanation of a topic that always puzzled me. > Personally, I could live with SIGFPE just aborting the program. I'm also > curious: is it possible to catch floating point errors in ocaml's bytecode? > Or is this, too, dependent on the ansi C/Posix standards? ISO C9X (the next generation C standard, not yet implemented by everyone) provides ways to test for pending floating-point exceptional conditions (overflows, NaNs, etc). It does not (AFAIK) standardize an API to turn some/all of these conditions into signals. So, once C9X becomes common enough, the bytecode interpreter could conceptually check after each floating-point operation. I doubt we'll ever do this, however, given that the IEEE "no exception" model seems to become universal, even if you don't like it :-) (See below.) > I tried this with java and was interested to find that integer > division by zero is caught but floating point division by zero isn't. It is "caught" not as an exception, but by returning the appropriate values defined for this very purpose in IEEE arithmetic: 1.0 / 0.0 = +Inf -1.0 / 0.0 = -Inf 0.0 / 0.0 = NaN This might not seem natural to you, but it's the result of years of arguing among numerical experts, and is the standard towards which both hardware and programming languages converge. - Xavier Leroy ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners