unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Daniel Hartwig <mandyke@gmail.com>
Cc: guile-devel@gnu.org
Subject: Re: Why 'inexact' and 'exact' doesn't check 'number?' first?
Date: Wed, 12 Dec 2012 01:32:53 -0500	[thread overview]
Message-ID: <87vcc793vu.fsf@tines.lan> (raw)
In-Reply-To: <CAN3veReogRPvXT-E9FSznGMo_evrkOo_HHiRYaovZ9-O8D9EPQ@mail.gmail.com> (Daniel Hartwig's message of "Wed, 12 Dec 2012 14:07:44 +0800")

Daniel Hartwig <mandyke@gmail.com> writes:
> On 12 December 2012 13:55, Nala Ginrut <nalaginrut@gmail.com> wrote:
>> Are you suggesting I use (is-a? obj <fraction>) for 'fraction?' ?
>
> Absolutely not.  Use inexact? if you wish to determine that the
> *storage* of a value is using floating point format.

Apologies in advance for being pedantic, but there is no guarantee that
inexact numbers are represented in floating point format.  Having said
that, I'm not aware of any current Scheme implementation that uses a
different representation for inexacts.

Nala Ginrut <nalaginrut@gmail.com> writes:
> (define (fraction? obj)
>   (and (number? obj) (inexact? obj)))

This definition implies that 3.1415927 is a fraction, and 1/2 is not.
I suspect you want something closer to this:

  (define (fraction? obj)
    (and (rational? obj)
         (exact? obj)
         (not (integer? obj))))

     Regards,
       Mark



  reply	other threads:[~2012-12-12  6:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-12  3:21 Why 'inexact' and 'exact' doesn't check 'number?' first? Nala Ginrut
2012-12-12  4:39 ` Daniel Hartwig
2012-12-12  5:55   ` Nala Ginrut
2012-12-12  6:07     ` Daniel Hartwig
2012-12-12  6:32       ` Mark H Weaver [this message]
2012-12-12  6:39         ` Daniel Hartwig
2013-01-21 20:52 ` Andy Wingo

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=87vcc793vu.fsf@tines.lan \
    --to=mhw@netris.org \
    --cc=guile-devel@gnu.org \
    --cc=mandyke@gmail.com \
    /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).