rust-num / num-rational

Generic Rational numbers for Rust
Apache License 2.0
144 stars 51 forks source link

add `limit_denominator` method with tests #103

Open msalib opened 2 years ago

msalib commented 2 years ago

Python's fractions module in the standard library implements a rational type and provides a really handy limit_denominator method. I've implemented it here along with some tests.

This PR should address #99 .

cmpute commented 2 years ago

FWIW, I would suggest creating a uniform method/trait to approximate numbers (as I proposed in #100), which should work for both float to rational and rational to rational conversions.

cuviper commented 2 years ago

I appreciate that you cited your source, but I'm also uncomfortable with the license implications there. I think language translations do still generally count as derived works. I'm not really sure what we need to do about that...