Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

How do I convert a number to a fraction and vice versa?

by PodMaster (Abbot)
on Jul 26, 2003 at 06:28 UTC ( #278079=perlquestion: print w/replies, xml ) Need Help??

PodMaster has asked for the wisdom of the Perl Monks concerning the following question: (numbers)

Originally posted as a Categorized Question. Body may be blank.

  • Comment on How do I convert a number to a fraction and vice versa?

Replies are listed 'Best First'.
Re: How do I convert a number to a fraction and vice versa?
by PodMaster (Abbot) on Jul 26, 2003 at 06:32 UTC
    use Number::Fraction; my ( @dimensions ) = ( 320,240 ); my $aspect = Number::Fraction->new(@dimensions); print "\n\n", join('x', @dimensions), ' ', $aspect->to_num, " ", $aspect, "\n\n"; __END__ 320x240 1.33333333333333 4/3

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://278079]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2019-09-22 22:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The room is dark, and your next move is ...












    Results (274 votes). Check out past polls.

    Notices?