From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ian Price Newsgroups: gmane.lisp.guile.user Subject: Re: (real? (* +i +i)) -> #f Date: Fri, 03 Aug 2012 11:33:25 +0100 Message-ID: <87r4rotgcq.fsf@Kagami.home> References: <34250234.post@talk.nabble.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1343990033 30686 80.91.229.3 (3 Aug 2012 10:33:53 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 3 Aug 2012 10:33:53 +0000 (UTC) Cc: Guile-user@gnu.org To: JihemD Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Aug 03 12:33:53 2012 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 1SxFCW-0000dz-OR for guile-user@m.gmane.org; Fri, 03 Aug 2012 12:33:48 +0200 Original-Received: from localhost ([::1]:34580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxFCV-0005CT-Kz for guile-user@m.gmane.org; Fri, 03 Aug 2012 06:33:47 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:36571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxFCM-0005C5-IK for Guile-user@gnu.org; Fri, 03 Aug 2012 06:33:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SxFCH-0008Sy-VK for Guile-user@gnu.org; Fri, 03 Aug 2012 06:33:38 -0400 Original-Received: from mail-wi0-f171.google.com ([209.85.212.171]:47943) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxFCH-0008SR-PG for Guile-user@gnu.org; Fri, 03 Aug 2012 06:33:33 -0400 Original-Received: by wibhq4 with SMTP id hq4so4507939wib.12 for ; Fri, 03 Aug 2012 03:33:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=w+yLN7BkCrfiJocUrWIzQU9k/CsxMmLYAjub53add6I=; b=ViP8ylsPX8iW9ng+ryXlEC39+Y+RfO4Iz3/YnQI+ZSHvXTXzjVW9/+ZuDh5JbnKWlz +cDPhSBsx876CvYlrV8QOsGWpD10Wj44d5sxYTX24RCI88Vof11X0I9cS7kF6S4Ej5Lh WMDLoU2K0MWdPap73iW7hxYIILns5Er/MFde14N4NhOPtzpPytN/C+09tnSmQCQFNedU DBMXyrlmD2NemqOX2zZd+M6hrxfEsrg+ioEFRR/pX4GU+mQBSqRvVX4uZJ8dFETN6sZv vD9BfTIOS5KBvBmM2Ne4ECDumq3yoIHTjCqLIosvD0QvaI606m+FifY9AyPFUGkS44N3 61vQ== Original-Received: by 10.180.78.170 with SMTP id c10mr12283955wix.3.1343990012679; Fri, 03 Aug 2012 03:33:32 -0700 (PDT) Original-Received: from Kagami.home (host31-53-17-56.range31-53.btcentralplus.com. [31.53.17.56]) by mx.google.com with ESMTPS id o2sm24872102wiz.11.2012.08.03.03.33.30 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 03 Aug 2012 03:33:31 -0700 (PDT) In-Reply-To: <34250234.post@talk.nabble.com> (JihemD's message of "Fri, 3 Aug 2012 03:02:03 -0700 (PDT)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.212.171 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:9545 Archived-At: JihemD writes: > Hi > I am playing around with Guile 2.05 on Kubuntu 12.04,=20 > why : > scheme@(guile-user)> (real? (* +i +i)) > $13 =3D #f > but : > scheme@(guile-user)> (zero? (imag-part (* +i +i))) > $14 =3D #t > > thxs I believe guile only considers numbers with an _exact_ 0 imaginary part to be real. However, since all guile complex numbers are inexact, this means that (* +i +i) is not considered real. scheme@(guile=E2=88=92user)> (* +i +i) $19 =3D =E2=88=921.0+0.0i scheme@(guile=E2=88=92user)> (exact? (imag-part $19)) $20 =3D #f While I don't know if this was a specific concern when writing, this is in line with the interpretation in section 11.7.4 Numerical operations of the r6rs document. http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-14.html#node_sec_11.7.4.1 If x is a real number object, then (rational? x) is true if and only if there exist exact integer objects k1 and k2 such that (=3D x (/ k1 k2)) and (=3D (numerator x) k1) and (=3D (denominator x) k2) are all true. Thus infinities and NaNs are not rational number objects. (real? -2.5+0.0i) =E2=87=92 #f (real? -2.5+0i) =E2=87=92 #t --=20 Ian Price "Programming is like pinball. The reward for doing it well is the opportunity to do it again" - from "The Wizardy Compiled"