unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* How to format exact rationals?
@ 2010-05-21 12:45 Sascha Ziemann
  2010-05-21 17:35 ` Andy Wingo
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Ziemann @ 2010-05-21 12:45 UTC (permalink / raw)
  To: guile-user

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

If so how to format them?



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to format exact rationals?
  2010-05-21 12:45 How to format exact rationals? Sascha Ziemann
@ 2010-05-21 17:35 ` Andy Wingo
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Wingo @ 2010-05-21 17:35 UTC (permalink / raw)
  To: Sascha Ziemann; +Cc: guile-user

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/



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-21 17:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-21 12:45 How to format exact rationals? Sascha Ziemann
2010-05-21 17:35 ` Andy Wingo

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).