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.
oh, like "maxima" does??
..Try "1.514"... idk..
what's [maxima] ?
if you need to know that 0.25 = 1/4 though, this object is what you need!
yeah good to know...
Maxima is a "CAS" ( http://maxima.sourceforge.net/ )
It has got a function called ratsimp() that does what you want (..and more..)
I'm not quite shure but I think one can access that functions "core" somehow (some "lisp"-stuff or whatever). ..maybe to have a look how the maxima-guys did that job...
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!