On 19/01/2008, Jeffrey Yasskin <jyasskin at gmail.com> wrote: > The first returns the closest rational whose denominator is less than > a given integer. [...] > The second returns the simplest rational within some distance. Both of these are likely to be of limited use. The most common usage I know of is to make a "sensible" rational from a float (i.e., a DWIM style conversion 0.1 -> 1/10) or to provide readable output. On the other hand, both are subtle to implement, so having a standard implementation saves people having to code (and debug) their own. I suspect that simplest within a particular distance is the form that is most often wanted, but I don't have any good evidence for that feeling. Putting both in might help people to realise that there *is* a choice. Given that you have implemented them, I'd say leave them in. And I like the names trim and approximate, as given in the code you referenced. Paul.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4