Rick Regan on Thu, 04 Jun 2009 21:43:57 +0200

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Is There a Way to Rationalize a Decimal in Pari/GP?

I'm looking for an automated way to turn a decimal value into a
fraction in the PARI/GP calculator (gp). For example, I want to turn
0.759765625 into 389/512. I know I can do this manually by typing in
'759765625/10^9', but I'd like an easier way, like
'rationalize(0.759765625);' would work in Maxima.

If it can't do this directly, maybe there's a function to count the
number of decimal places? Then I could raise 10 to the result of that
function. (The function would have to count leading decimal places of
0s to be useful.)


Rick Regan

“There are 10 types of people ... those who understand binary and
those who don't” -- http://www.exploringbinary.com