unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: JihemD <jihem01@online.fr>
Cc: Guile-user@gnu.org
Subject: Re: (real? (* +i +i)) -> #f
Date: Tue, 07 Aug 2012 15:04:13 -0400	[thread overview]
Message-ID: <502166AD.3060702@netris.org> (raw)
In-Reply-To: <34250234.post@talk.nabble.com>

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



      parent reply	other threads:[~2012-08-07 19:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-03 10:02 (real? (* +i +i)) -> #f JihemD
2012-08-03 10:33 ` Ian Price
2012-08-03 11:04   ` JihemD
2012-08-07 19:04 ` Mark H Weaver [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=502166AD.3060702@netris.org \
    --to=mhw@netris.org \
    --cc=Guile-user@gnu.org \
    --cc=jihem01@online.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).