John Fremlin's blog: Dynamic Lisp blog entry demo: rationalize

Posted 2014-03-13 07:00:00 GMT

Given a floating point number, how to go to its representation as a rational?

1.0471976 = 1/3π

Try another number:

Thanks to the RATIONALIZE function in Common Lisp. See the SBCL source.

Updated to not show d0 at the end

Posted 2014-03-13 08:03:49 GMT by John Fremlin

Thank you for this.

Interestingly, on LispWorks:

CL-USER 1 > (rationalize 1.0471972)



* (rationalize 1.0471972)


Posted 2020-01-28 14:09:54 GMT by Priyadarshan

Post a comment