From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Nelson H. F. Beebe" Newsgroups: gmane.lisp.guile.devel Subject: Re: guile-core-20020426 and IEEE 754 arithmetic Date: Thu, 16 May 2002 07:06:41 -0600 (MDT) Sender: guile-devel-admin@gnu.org Message-ID: NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1021554547 21986 127.0.0.1 (16 May 2002 13:09:07 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 16 May 2002 13:09:07 +0000 (UTC) Cc: beebe@math.utah.edu, jwe@bevo.che.wisc.edu, Marius Vollmer Return-path: Original-Received: from fencepost.gnu.org ([199.232.76.164]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 178L0F-0005iO-00 for ; Thu, 16 May 2002 15:09:07 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 178L0M-0007Ln-00; Thu, 16 May 2002 09:09:14 -0400 Original-Received: from sunshine.math.utah.edu ([128.110.198.2]) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 178Ky0-0007Bw-00 for ; Thu, 16 May 2002 09:06:48 -0400 Original-Received: from plot79.math.utah.edu (IDENT:shfl+CK78x+O7thwbUob36EYJ9Hsuxs+@plot79.math.utah.edu [128.110.198.20]) by sunshine.math.utah.edu (8.9.3/8.9.3) with ESMTP id HAA01164; Thu, 16 May 2002 07:06:42 -0600 (MDT) Original-Received: (from beebe@localhost) by plot79.math.utah.edu (8.9.3/8.9.3) id HAA13057; Thu, 16 May 2002 07:06:41 -0600 (MDT) Original-To: guile-devel@gnu.org X-US-Mail: "Center for Scientific Computing, Department of Mathematics, 110 LCB, University of Utah, 155 S 1400 E RM 233, Salt Lake City, UT 84112-0090, USA" X-Telephone: +1 801 581 5254 X-FAX: +1 801 585 1640, +1 801 581 4148 X-URL: http://www.math.utah.edu/~beebe In-Reply-To: Your message of Thu, 16 May 2002 00:12:48 -0500 Errors-To: guile-devel-admin@gnu.org X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.devel:620 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:620 Thanks to Marius Vollmer and John W. Eaton for the reports of much improved handling of floating-point output in the current guile development sources! John asked about this fragment of my report: >> ... >> | (1) Output of small numbers is incorrect: >> | >> | (use-modules (ice-9 format)) >> | (let ((ratio (- 1.0 (expt 2 -53)))) >> | (while (> ratio (/ ratio 2)) >> | (format #t "~25,15g~%" ratio) >> | (set! ratio (* ratio 2))) >> | (format #t "~25,15g~%" ratio)) >> | >> | At Marius' suggestion, this was mostly fixed by this patch: >> | >> | % diff /usr/local/share/guile/site/ice-9/format.scm* >> | 1445c1445 >> | < (define format:fn-max 400) ; max. number of number digits >> | --- >> | > (define format:fn-max 200) ; max. number of number digits >> >> It's not clear from the diff which is the old and new. If it is >> supposed to be 400, then this change appears to be in the newer >> sources. >> ... Apologies for not making my diff of format.scm clearer: the changed file increased the buffer size from 200 to 400, fixing the problem with the display of large floating-point numbers. >> If (- 0.0) is a valid way to create a signed zero,... Another way to get a negative zero is (/ -1 Infinity): here's a summary of what my hoc, and guile and some other Lisp systems, do with this: hoc-7.0.x: hoc> x = 0 hoc> __hex(x) 0x00000000_00000000 == 0 0 hoc> y = -0 hoc> __hex(y) 0x80000000_00000000 == 0 0 hoc> y -0 hoc> z = 1 / -Inf hoc> __hex(z) 0x80000000_00000000 == 0 0 bigloo (2.5a) 1:=> -0.0 0.0 !WRONG 1:=> (- 0.0) 0.0 !WRONG 1:=> (/ -1 (/ 1.0 0.0)) 0.0 !WRONG guile-core-20020426 (1.5.6): guile> -0.0 0.0 !WRONG guile> (- 0.0) 0.0 !WRONG guile> (/ -1 (/ 1.0 0.0)) 0.0 !WRONG mzscheme 200alpha12 (PLT Scheme): > -0.0 -0.0 !OK > (- 0.0) -0.0 !OK > (/ -1 (/ 1.0 0.0)) -0.0 !OK Scheme Release 7.3.1 Microcode Version 11.146 Runtime 14.166 (MIT Scheme): 1 ]=> -0.0 ;Value: 0. !WRONG 1 ]=> (- 0.0) ;Value: 0. !WRONG 1 ]=> (/ -1 (/ 1.0 0.0)) ;Value: 0. !WRONG [By the way, that implementation produces #[+inf] and #[NaN] for Infinity and NaN.] emacs-21.2.2: (- 0.0) -0.0 !OK -0.0 -0.0 !OK (/ -1 (/ 1.0 0.0)) -0.0 !OK clisp 2.28 (released 2002-03-03): [1]> (- 0.0) 0.0 !WRONG [1]> -0.0 0.0 !WRONG [2]> (/ -1.0e-300 1.0e+300) *** - floating point underflow !BOTCH [3] (/ -1 (/ 1.0 0.0)) *** - division by zero !BOTCH gcl 2.2.2: >-0.0 0.0 !WRONG >(- 0.0) -0.0 !OK >(/ -1.0e-300 1.0e+300) -0.0 !OK >(/ -1 (/ 1.0 0.0)) Error: Zero divisor. !BOTCH A caution for implementers: when I tested hoc on several different platforms, I found that on a few, it produced 0 instead of -0: that is due to the underlying C printf() function's defective handling of negative zero. I will add code in the next hoc release to handle that special case. Similar experiments in with 50+ C, 35_ C++, and 30+ Fortran compilers, produce mixed results: correct handling of IEEE 754 negative zero remains elusive in those languages, despite that fact that the arithmetic system is now more than two decades old, and is in universal use on 100M+ desktop computer systems. ------------------------------------------------------------------------------- - Nelson H. F. Beebe Tel: +1 801 581 5254 - - Center for Scientific Computing FAX: +1 801 585 1640, +1 801 581 4148 - - University of Utah Internet e-mail: beebe@math.utah.edu - - Department of Mathematics, 110 LCB beebe@acm.org beebe@computer.org - - 155 S 1400 E RM 233 beebe@ieee.org - - Salt Lake City, UT 84112-0090, USA URL: http://www.math.utah.edu/~beebe - ------------------------------------------------------------------------------- _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel