Bill Allombert on Fri, 05 Jun 2009 19:59:13 +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?


On Fri, Jun 05, 2009 at 10:07:40AM -0400, Rick Regan wrote:
> 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...).

You can use someting like 
? valuation(denominator(3/512),2)
%3 = 9

Cheers,
Bill.