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: (real? (* +i +i)) -> #f Date: Tue, 07 Aug 2012 15:04:13 -0400 Message-ID: <502166AD.3060702@netris.org> References: <34250234.post@talk.nabble.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1344366287 31253 80.91.229.3 (7 Aug 2012 19:04:47 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 7 Aug 2012 19:04:47 +0000 (UTC) Cc: Guile-user@gnu.org To: JihemD Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Aug 07 21:04:48 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 1Syp5D-0004DO-4G for guile-user@m.gmane.org; Tue, 07 Aug 2012 21:04:47 +0200 Original-Received: from localhost ([::1]:53808 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Syp5C-0002GZ-Dj for guile-user@m.gmane.org; Tue, 07 Aug 2012 15:04:46 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:51327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Syp57-0002GE-Kw for Guile-user@gnu.org; Tue, 07 Aug 2012 15:04:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Syp56-0000ZM-Jf for Guile-user@gnu.org; Tue, 07 Aug 2012 15:04:41 -0400 Original-Received: from world.peace.net ([96.39.62.75]:42182) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Syp56-0000YH-Fh for Guile-user@gnu.org; Tue, 07 Aug 2012 15:04:40 -0400 Original-Received: from 209-6-92-20.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.92.20] helo=[10.0.1.9]) by world.peace.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1Syp4v-0000cp-2n; Tue, 07 Aug 2012 15:04:29 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.5) Gecko/20120624 Icedove/10.0.5 Original-Newsgroups: gmane.lisp.guile.user In-Reply-To: <34250234.post@talk.nabble.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:9547 Archived-At: On 08/03/2012 06:02 AM, JihemD wrote: > I am playing around with Guile 2.05 on Kubuntu 12.04, > why : > scheme@(guile-user)> (real? (* +i +i)) > $13 = #f > but : > scheme@(guile-user)> (zero? (imag-part (* +i +i))) > $14 = #t In recent Scheme standards (both R6RS and draft R7RS), a number is considered real if and only if the imaginary part is an _exact_ zero. See the definitions of 'real?' in R6RS section 11.7.4 and R7RS section 6.2.6. The R6RS Rationale document provides some discussion in the "Flow analysis" portion of section 11.6.6. The R6RS provides a 'real-valued?' predicate that might be closer to what you expect. You can get it in Guile by importing (rnrs base). As Ian noted, Guile does not currently support exact non-real complex numbers, so +i cannot be represented exactly, and thus the imaginary part of +i^2 is not known to be exactly zero. If we add support for exact non-real complex numbers some day, then (real? (* +i +i)) will become #t. > Thx Ian, the concept of exactness is new for me The concept of exact numbers is described in R6RS section 3.2. Mark