Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: decimal to fraction

by Laurent_R (Canon)
on Sep 24, 2017 at 11:48 UTC ( #1199989=note: print w/replies, xml ) Need Help??


in reply to decimal to fraction

The same with Perl 6:
> say 0.421875.nude (27 64) >
Note: nude stands for numerator-denominator.

Replies are listed 'Best First'.
Re^2: decimal to fraction
by no_slogan (Deacon) on Sep 24, 2017 at 15:30 UTC
    > 0.49420098210293.nude (49420098210293 100000000000000) > 0.49420098210293.Num().Rat(1e-15).nude (463051 936969)
    Yay Perl6. Took me a while to figure out the magic incantation, because the Perl6 documentation is nigh incomprehensible. Also, Rat() ignores the epsilon parameter if it's called on a rational. Sometimes, you'd like to find a fraction that's an approximation of another fraction without mashing it down to a float first.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1199989]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2017-12-16 01:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (447 votes). Check out past polls.

    Notices?