unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: Sascha Ziemann <ceving@googlemail.com>
Cc: guile-user@gnu.org
Subject: Re: How to format exact rationals?
Date: Fri, 21 May 2010 19:35:05 +0200	[thread overview]
Message-ID: <m3mxvtxinq.fsf@pobox.com> (raw)
In-Reply-To: <AANLkTilR8sUg0aJlkmr6HxMggF7NxWKtumkWT4mj7701@mail.gmail.com> (Sascha Ziemann's message of "Fri, 21 May 2010 14:45:48 +0200")

Hi,

On Fri 21 May 2010 14:45, Sascha Ziemann <ceving@googlemail.com> writes:

> Is this the intended behavior for exact rationals?
>
> guile> (format #f "~f" (/ 1 3))
>
> FORMAT: error with call: (format #f "~f<===" ===>1/3 )
>         illegal character `/' in number->string

I don't know. There is some pretty gnarly code there; for some reason it
takes the argument, does number->string on it, parses the resulting
string, and there it's failing because it doesn't seem to handle exact
rationals.

But, as rationals are real numbers, just as the exact integers, we
should expect this function to format (/ 1 3) appropriately.

> If so how to format them?

As a workaround, use `(format #f "~f" (exact->inexact (1/3)))'. I'll
commit a real fix to master sometime soon.

Andy
-- 
http://wingolog.org/



      reply	other threads:[~2010-05-21 17:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-21 12:45 How to format exact rationals? Sascha Ziemann
2010-05-21 17:35 ` Andy Wingo [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=m3mxvtxinq.fsf@pobox.com \
    --to=wingo@pobox.com \
    --cc=ceving@googlemail.com \
    --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).