[issue31978] make it simpler to round fractions

Serhiy Storchaka report at bugs.python.org
Wed Nov 8 09:36:09 EST 2017


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

I thought about adding a public function in the math module when worked on one of that functions. But there are not many cases for it in the stdlib (datetime, fractions, decimal, and maybe it's all). I don't know whether there is a common enough need in third-party code. But there is a parallel with math.remainder().

If add this function, I would implement it in C and add in the math module. It already contains integer specific functions factorial() and gcd(). There was a proposition to add as_integer_ratio() (which will work with arbitrary rationals). All together they will create a small integer mathematics domain in the math module. Or can be extracted in a special module. Later it can be extended by adding functions for binomial coefficients and the number of permutations and generators of prime and Fibonacci numbers.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31978>
_______________________________________


More information about the Python-bugs-list mailing list