× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Wed, Dec 21, 2016 at 1:11 PM, Gerald Magnuson
<gmagqcy.midrange@xxxxxxxxx> wrote:
That question (what about "non clean" fractions) has not yet been
answered...
the initial response was "that doesn't happen"... ;)

The moment you count on it not happening, it will.

Building a table is probably the best bet, if you only need it to be
accurate to .01 or so. It's not like anybody is ever going to ask for
a fractional approximation of pi accurate to four or five decimal
places. It'd be a cool routine, though, if it could return fractions
accurate to a desired amount.

Valid values for pi would be:
3/1
22/7
333/106
355/113
103993/33102 and so on. As pi is transcendental, we never get there.

The code is actually not that difficult; you just use continuing
fractions (https://en.wikipedia.org/wiki/Continued_fraction#Best_rational_approximations)

Can't think of much of a business use, but I'm pretty sure I've got
most of the code already written. If I have a slow afternoon over the
holidays, I'll wrap it up in service program:

returnFraction( decimalValue : accuracy : numerator : denominator )
and post a link.

Easy to test; if you run it for phi (the golden mean) your numerator
and denominator will always be adjacent Fibonacci numbers.

Chris
www.brilligware.com - Home of MineSweeper5250




On Wed, Dec 21, 2016 at 1:03 PM, Paul Therrien <
paultherrien@xxxxxxxxxxxxxxxxxx> wrote:

I am curious. Are the numbers coming in always going to result in clean
fractions?
What would be the resulting fraction if the incoming number was 0.03126?
1/31.98976; 1/31.99?; 1/32?




Depending upon the desired level of accuracy:
1/31
1/32
97/3103
98/3135
293/9373
1563/50000

The last one, of course, is exact.

---
Chris
www.brilligware.com - Home of MineSweeper5250

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.