Message413423
> 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". |
|
Date |
User |
Action |
Args |
2022-02-17 18:09:50 | mark.dickinson | set | recipients:
+ mark.dickinson, rhettinger, zach.ware, serhiy.storchaka, Leengit |
2022-02-17 18:09:50 | mark.dickinson | set | messageid: <1645121390.52.0.015988907549.issue46780@roundup.psfhosted.org> |
2022-02-17 18:09:50 | mark.dickinson | link | issue46780 messages |
2022-02-17 18:09:50 | mark.dickinson | create | |
|