Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.forth Subject: Re: real to rational number Date: Thu, 20 Apr 2017 11:46:40 -0700 Organization: A noiseless patient Spider Lines: 10 Message-ID: <87wpaedii7.fsf@nightsong.com> References: <87inlzerp1.fsf@nightsong.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="efdb76e8249dce14a596c997ec8f2e8c"; logging-data="22135"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/80rpofNi3VDJym0YkbxXU" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:8nL/IY1c7Ce1X3sKoKAtuVyDFpo= sha1:NS/qp4rt47l6kXVkwBNZdUvsV14= Xref: csiph.com comp.lang.forth:57659 "Rudy Velthuis" writes: > Then I don't quite understand it. If you already have a mathematical > real, then what is the problem? You want to find a rational approximation to your mathematical real. E.g. suppose your real is pi. You could use 31/10 as an approximation, but it turns out 22/7 is closer. If you want even better, 355/113 is extremely close. How do you find these fractions? You could do a brute force search through possible denominators, but there's a much faster algorithm using continued fractions that I posted.