From: JihemD <jihem01@online.fr>
To: Guile-user@gnu.org
Subject: Re: (real? (* +i +i)) -> #f
Date: Fri, 3 Aug 2012 04:04:29 -0700 (PDT) [thread overview]
Message-ID: <34250430.post@talk.nabble.com> (raw)
In-Reply-To: <87r4rotgcq.fsf@Kagami.home>
Ian Price wrote:
>
> 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−user)> (* +i +i)
> $19 = −1.0+0.0i
> scheme@(guile−user)> (exact? (imag-part $19))
> $20 = #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 (= x (/ k1 k2))
> and (= (numerator x) k1) and (= (denominator x) k2) are all true. Thus
> infinities and NaNs are not rational number objects.
>
> (real? -2.5+0.0i) ⇒ #f
> (real? -2.5+0i) ⇒ #t
>
> --
> Ian Price
>
Thx Ian, the concept of exactness is new for me :
scheme@(guile-user)> (real? +0i)
$1 = #t
scheme@(guile-user)> (inexact->exact 1.0)
$2 = 1
scheme@(guile-user)> (inexact->exact (* +i +i))
$3 = -1
scheme@(guile-user)> (* +i +i)
$4 = -1.0+0.0i
scheme@(guile-user)> (real? (* +i +i))
$5 = #f
scheme@(guile-user)> (real? (inexact->exact (* +i +i)))
$6 = #t
--
View this message in context: http://old.nabble.com/%28real--%28*-%2Bi-%2Bi%29%29--%3E--f-tp34250234p34250430.html
Sent from the Gnu - Guile - User mailing list archive at Nabble.com.
next prev parent reply other threads:[~2012-08-03 11: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 [this message]
2012-08-07 19:04 ` Mark H Weaver
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=34250430.post@talk.nabble.com \
--to=jihem01@online.fr \
--cc=Guile-user@gnu.org \
/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).