Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: bignum usage?

by kcott (Archbishop)
on Oct 15, 2023 at 05:04 UTC ( [id://11154953]=note: print w/replies, xml ) Need Help??

in reply to bignum usage?

G'day rkd257,

Welcome to the Monastery.

"... thought I would end up with 5 and 7 ... ## $cf = 7/12 ..."

So, I think you should have been expecting 7 and 12. If not, please explain why 5 and 7?

Anyway, I think you want bigrat; not Math::BigRat and bignum. (All three are core modules.)

$ perl -e ' use bigrat; my $cf = 1 - 1/6 - 1/4; my $n = $cf->numerator(); my $d = $cf->denominator(); print "$cf\n"; print " $n\n"; print " $d\n"; ' 7/12 7 12

— Ken

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11154953]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (8)
As of 2024-05-21 20:58 GMT
Find Nodes?
    Voting Booth?

    No recent polls found