[Tutor] Need help with rewriting script to use Decimal module

Dick Moores rdm at rcblue.com
Thu Jan 4 17:57:35 CET 2007


At 08:20 AM 1/4/2007, Terry Carroll wrote:
>On Wed, 3 Jan 2007, Dick Moores wrote:
>
> > Terry, I just noticed that farey(0.36, 10) returns (1, 3), a pretty
> > big miss, IMO. The correct fraction with smallest error and maximum
> > denominator of 10 is 3/8, which I'm proud to say my klunky frac.py
> > (<http://www.rcblue.com/Python/fracForWeb.py>) produces.
>
>Dick, good catch.  Consider adding a comment to the Cookbook page pointing
>out that the method sometimes does not produce the incorrect answer,
>including for that input.

Done.

Dick





More information about the Tutor mailing list