just posted this on the mailing list, thought i may as well pop it on here as well.
converts decimals to fractions.
Decimal to fraction
just posted this on the mailing list, thought i may as well pop it on here as well.
converts decimals to fractions.
Here is my attempt, based on:
http://en.wikipedia.org/wiki/Continued_fraction#Best_rational_approximations
It doesn't implement the rules for decrementing the last value of the continued fraction, but it works well for simple rational fractions. Hopefully I'll get around to implementing those rules for accurate irrational estimations.
P.S. THIS SHOULD BE IN ABSTRACT~, MOD. ;-p
Here is my attempt, based on:
http://en.wikipedia.org/wiki/Continued_fraction#Best_rational_approximations
It doesn't implement the rules for decrementing the last value of the continued fraction, but it works well for simple rational fractions. Hopefully I'll get around to implementing those rules for accurate irrational estimations.
P.S. THIS SHOULD BE IN ABSTRACT~, MOD. ;-p
I should mention that it does run into stack overflows from time to time if the argument is too high. Not sure how to fix that one, yet.
Edit: Nevermind. Just fixed it.
i'm so glad you got this going. i spent ages on it and failed.
I just re-uploaded this to fix a bug with the right inlet.
i ninja-edited my first post with a working version.
I think yours wins, mod. Much more compact than mine.
it's mattieu's bit that's super compact. That expr object feeding back into itself, i would never have thought of in a million years - i just didn't (and still don't really) understand the number theory behind it.
Nice work, mod.
Oops! Looks like something went wrong!