Mark Dickinson <dicki...@gmail.com> added the comment:

> the constructed Fraction first computes the range of the values that the 
> input string could have been rounded from

There's too much magic and guesswork here for my liking; I don't really see 
this as feasible. Moreover, depending on which rounding mode was used 
(round-ties-to-even, round-ties-to-away), the interval may be half-open, open 
or closed.

For another problematic example, suppose the string supplied is "0.10". How are 
we to guess whether this was the result of rounding to two decimal places after 
the point (in which case the interval we need is [0.095, 0.105]), or whether 
it's the result of rounding to two significant figures (in which case the 
interval we need is [0.095, 0.15])?

> and then computes the fraction in that half-open interval with the lowest 
> numerator and denominator

This part, however, is well-defined and can be done efficiently. You may be 
interested in the "simplefractions" module on PyPI, which solves the exact task 
"find the simplest fraction in a given interval".

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46780>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to