http://www.perlmonks.org?node_id=11154953


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