This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients Leengit, mark.dickinson, rhettinger, serhiy.storchaka, zach.ware
Date 2022-02-17.18:09:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1645121390.52.0.015988907549.issue46780@roundup.psfhosted.org>
In-reply-to
Content
> 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".
History
Date User Action Args
2022-02-17 18:09:50mark.dickinsonsetrecipients: + mark.dickinson, rhettinger, zach.ware, serhiy.storchaka, Leengit
2022-02-17 18:09:50mark.dickinsonsetmessageid: <1645121390.52.0.015988907549.issue46780@roundup.psfhosted.org>
2022-02-17 18:09:50mark.dickinsonlinkissue46780 messages
2022-02-17 18:09:50mark.dickinsoncreate