Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Percentages to Fractions

by I0 (Priest)
on Feb 22, 2004 at 05:29 UTC ( #330889=note: print w/replies, xml ) Need Help??


in reply to Percentages to Fractions

use strict; use POSIX; sub cf{ my($v,$p) = @_; my $i=int $v; $v -= $i; if( fabs($v)>$p ){ my($a,$n,$d)=cf(1/$v,$p*(1+abs$i)); return $i,$d,$a*$d+$n }else{ return $i,0,1; } } while( <DATA> ){ chomp; my ($i,$n,$d) = cf($_,.001); $n+=$i*$d; print "$_:\t$n/$d\n"; } __DATA__ 0.035 0.037 0.039 0.041 0.043 0.046 0.048

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://330889]
help
Chatterbox?
[Corion]: ambrus: AnyEvent(::HTTP) doesn't integrate well with Prima, that's my main problem
[Corion]: There is a weirdo shim because there is a POE integration for Prima, and if you use that, you can use the POE adapter of AnyEvent. What I'd want is something transport agnostic that parses HTTP or produces HTTP output, so that the communication with ...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2016-12-07 15:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (130 votes). Check out past polls.