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?

 To: pariusers@list.cr.yp.to
 Subject: Is There a Way to Rationalize a Decimal in Pari/GP?
 From: Rick Regan <exploringbinary@gmail.com>
 Date: Thu, 4 Jun 2009 09:47:48 0400
 Deliverydate: Thu, 04 Jun 2009 21:43:57 +0200
 Dkimsignature: v=1; a=rsasha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkeysignature:mimeversion:received:date:messageid:subject :from:to:contenttype:contenttransferencoding; bh=27drFoNgkukcZG2zo1b2OrQDDx/eGTxfxZN51d9wcqI=; b=mHMm4kClCate0lzOU0doz+msbgBPmgZcy4YUU1UOto9On9u+soQES0a1E37um25xsz QCEvJ327RBB+Kq/yh1/Wbd7tHo2+QbTjHI9O3VC2MOdyMpsbseF/65/qWr3ME5NyBPVd ebKEY3tGZb4cXqbxdlu6ReEjxVBfVGdOspoZY=
 Domainkeysignature: a=rsasha1; c=nofws; d=gmail.com; s=gamma; h=mimeversion:date:messageid:subject:from:to:contenttype :contenttransferencoding; b=o/1FwlYuGYK+V3PtmpVN8wFSQIZUhE9K40/L9L8LH/YqzhpGGE3B36i8vgJ9jU0THd 4EJzWpHzEf9tFc/UlqERnP17Mrjj1QmHqeT1+sMJoV15VNx69GgfTej0k97glNKOUMgO zXWanAZ0mT21z5IG8XtYuWT6hFPKgBlOeDqlM=
 Mailinglist: contact pariusershelp@list.cr.yp.to; run by ezmlm
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.)
Thanks.
Rick Regan

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