Rick Regan on Fri, 05 Jun 2009 19:43:47 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Is There a Way to Rationalize a Decimal in Pari/GP? |
I didn't mention that I am only looking at this from a limited point of view. I want to convert dyadic decimal fractions -- those that represent double-precision floating-point binary values. They are always terminating decimals. My aim is to reduce them to the form a/2^n, which bestappr() does (except that the power of two is given as a constant, and not as 2^n. I can find n with factor() but if you know of a more direct way...). On Fri, Jun 5, 2009 at 9:40 AM, John Cremona <john.cremona@gmail.com> wrote: > It was not supposed to be off list ;) > > bestappr() uses continued fractions, and cannot do better than the > precision you give it, so it is not very clear what the "exact > fraction" is (unless you specify the decimal expansion in such detail > that the full period is seen!) > > John > > 2009/6/5 Rick Regan <exploringbinary@gmail.com>: >> Thanks Bill (and John who contacted me off list). -- bestappr() does the trick! >> >> In my case I always want the exact fraction, so I have to make sure I >> specify a large enough denominator. I am converting long decimals, and >> I don't want to count decimal places. The easy solution seems to be to >> pass bestappr() an arbitrarily large power of 10, like >> bestappr(0.1000000000000000055511151231257827021181583404541015626,10^100). >> >> Rick >> >> -- >> “There are 10 types of people ... those who understand binary and >> those who don't” -- http://www.exploringbinary.com >> > -- “There are 10 types of people ... those who understand binary and those who don't” -- http://www.exploringbinary.com