From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.user Subject: Re: Can somebody help to explain why result from atan does not equal a real? Date: Thu, 31 Jan 2013 18:51:50 -0500 Message-ID: <87txpwgbc9.fsf@tines.lan> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1359676446 19252 80.91.229.3 (31 Jan 2013 23:54:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 31 Jan 2013 23:54:06 +0000 (UTC) Cc: guile-user@gnu.org To: Hengqing Hu Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Feb 01 00:54:26 2013 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1U13xR-0006tr-Ux for guile-user@m.gmane.org; Fri, 01 Feb 2013 00:54:18 +0100 Original-Received: from localhost ([::1]:53970 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U13x9-0006qm-LJ for guile-user@m.gmane.org; Thu, 31 Jan 2013 18:53:59 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:55144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U13x5-0006qh-7b for guile-user@gnu.org; Thu, 31 Jan 2013 18:53:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U13wz-0004NW-PJ for guile-user@gnu.org; Thu, 31 Jan 2013 18:53:55 -0500 Original-Received: from world.peace.net ([96.39.62.75]:59704) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U13wi-0004Jk-H5 for guile-user@gnu.org; Thu, 31 Jan 2013 18:53:49 -0500 Original-Received: from turntable.mit.edu ([18.160.0.29] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1U13wZ-0004GQ-Ez; Thu, 31 Jan 2013 18:53:23 -0500 In-Reply-To: (Hengqing Hu's message of "Thu, 31 Jan 2013 18:50:43 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 96.39.62.75 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:9961 Archived-At: Hengqing Hu writes: > The following behavior is observed on both guile 1.8 and guile 2.0. > Is it correct? > Can somebody elaborate why it happens? > > guile> (atan 0 -1) > 3.14159265358979 > guile> (= 3.14159265358979 3.14159265358979) > #t > guile> (= (atan 0 -1) 3.14159265358979) > #f Sorry, this is due to an inadequate 'number->string' implementation in Guile. A proper implementation should guarantee that when the string is read back in, you'll get precisely the same number back, and recent Scheme standards mandate this. At present, Guile does not always print enough digits to guarantee this. I plan to soon rewrite Guile's 'number->string' based on "Printing Floating-Point Numbers Quickly and Accurately" by Dybvig and Burger. I recently started that work but became distracted by more pressing matters. I hope to get back to it soon. Regards, Mark