From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA17063 for caml-redistribution; Mon, 13 Dec 1999 13:10:38 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA04133 for ; Mon, 13 Dec 1999 11:45:25 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id LAA00029; Mon, 13 Dec 1999 11:45:22 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA32753; Mon, 13 Dec 1999 11:45:22 +0100 (MET) Message-ID: <19991213114521.29847@pauillac.inria.fr> Date: Mon, 13 Dec 1999 11:45:21 +0100 From: Xavier Leroy To: Christophe Raffalli Cc: caml-list@inria.fr Subject: Re: Plea for inline expansion of transcendentals. References: <000f01bf4246$81914b30$210148bf@dylan> <19991211163135.00749@pauillac.inria.fr> <3854BA45.B83D7D66@univ-savoie.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1 In-Reply-To: <3854BA45.B83D7D66@univ-savoie.fr>; from Christophe Raffalli on Mon, Dec 13, 1999 at 09:20:05AM +0000 Sender: weis > It seems better to fail in this case, as the part of the number > which is significant for these periodic functions is completely lost > by the machine precision, so the renormalization is useless, isn't > it ? Yes, the result of sin(2^64) is totally meaningless. However, the Single Unix specification doesn't say that there is a range of values for the argument of "sin" outside of which we can return an error (however, it says "The sin() function may lose accuracy when its argument is far from 0.0", which could be interpreted as "we can return any wrong result"...) > The best would be to trap and raise an ML exception (Silly_Trigo :-). The trapping itself isn't trivial and requires a few instructions, making the inlining of "sin" less interesting. > Actually ocaml2.04 toplevel (I have not try the compilers) does > something very silly: > > # sin(10.0);; > - : float = -0.544021110889 > # sin(10e21);; > - : float = 1e+22 > > Using Ocaml I can therefore prove -1 < 1e+22 < 1 .... Whooo :-) Nice example. You must be using RedHat Linux 6 on a PC :-) The toplevel and bytecode compiler use whatever "sin" function is provided by the C compiler and C library. If the latter is correct, you'll get correct results. Your example works fine under Digital Unix, for instance. But it so happens that under RH 6.1, the "sin" function in the C library does the right thing (perform the "fsin" instruction, check for overflow, and normalize and try again if necessary), but "gcc -O" generates directly an "fsin" instruction -- "gcc" without -O calls the C library function. I view this as a gcc bug, though. - Xavier Leroy