[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to format exact rationals?

From: Andy Wingo
Subject: Re: How to format exact rationals?
Date: Fri, 21 May 2010 19:35:05 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux)


On Fri 21 May 2010 14:45, Sascha Ziemann <address@hidden> 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

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]