From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kamaraju S Kusumanchi Newsgroups: gmane.lisp.guile.devel Subject: asserting the equality of double values Date: Sat, 15 Sep 2007 13:53:59 -0400 Organization: Cornell University Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: sea.gmane.org 1189882242 30774 80.91.229.12 (15 Sep 2007 18:50:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 15 Sep 2007 18:50:42 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Sep 15 20:50:30 2007 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IWcir-0004wQ-MX for guile-devel@m.gmane.org; Sat, 15 Sep 2007 20:50:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IWcip-0007iU-RW for guile-devel@m.gmane.org; Sat, 15 Sep 2007 14:50:27 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IWcil-0007hh-C2 for guile-devel@gnu.org; Sat, 15 Sep 2007 14:50:23 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IWcik-0007hD-Mz for guile-devel@gnu.org; Sat, 15 Sep 2007 14:50:23 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IWcik-0007h9-KJ for guile-devel@gnu.org; Sat, 15 Sep 2007 14:50:22 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IWcik-0006x5-0g for guile-devel@gnu.org; Sat, 15 Sep 2007 14:50:22 -0400 Original-Received: from root by ciao.gmane.org with local (Exim 4.43) id 1IWciQ-0000fI-3X for guile-devel@gnu.org; Sat, 15 Sep 2007 20:50:02 +0200 Original-Received: from 209.150.235.30 ([209.150.235.30]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 15 Sep 2007 20:50:02 +0200 Original-Received: from kamaraju by 209.150.235.30 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 15 Sep 2007 20:50:02 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 45 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 209.150.235.30 User-Agent: KNode/0.10.5 X-Detected-Kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:6794 Archived-At: I was browsing the source code of guile 1.8.2 and have couple of trivial questions. I would be very grateful if you can answer the following questions. 1) In test-suite/standalone/test-round.c (lines 90-96) we have /* 2^DBL_MANT_DIG-1 In the past scm_c_round had incorrectly incremented this value, due to the way that x+0.5 would round upwards (in the usual default nearest-even mode on most systems). */ x = ldexp (1.0, DBL_MANT_DIG) - 1.0; assert (x == floor (x)); /* should be an integer already */ here ldexp and floor both return double values. Is it guaranteed that asserting the equality of two double values will always work? When learning C, I remember reading somewhere not to rely on such comparisons. I also do not understand the comment /* should be an integer already */ at the end of the line. AFAIK both ldexp, floor function return double values and not integers. Can someone explain the comment? I am interested in knowing this because guile 1.8.2 fails to build on a Debian machine using alpha architecture. According to the build log of the failure ( http://buildd.debian.org/fetch.cgi?&pkg=guile-1.8&ver=1.8.2%2B1-2&arch=alpha&stamp=1188100514&file=log ) it occurs around this part of the code. 2) The above code uses DBL_MANT_DIG macro. How can I easily find out where this macro is defined? Is there any book or reference which discuss this kind of macros. For now I did a grep in /usr/include and found that such a macro is defined in /usr/include/c++/4.2/limits file. This brings up another question. If you are using a macro defined in a standard c++ library header, shouldn't the file be named test-round.cpp instead of test-round.c? thanks raju -- Kamaraju S Kusumanchi http://www.people.cornell.edu/pages/kk288/ http://malayamaarutham.blogspot.com/ _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel