Math::Fraction v.3a

This is a small demonstration of what the fraction module can do.

It is run for the most part with this function.

sub pevel {print ">$_[0]\n"; $ans = eval $_[0]; print " $ans\n"; }

You can see it for yourself my typing demo in the fraction test script.

>frac(1, 3)
 1/3
>frac(4, 3, MIXED)
 1 1/3
>frac(1, 1, 3)
 4/3
>frac(1, 1, 3, MIXED)
 1 1/3
>frac(10)
 10/1
>frac(10, MIXED)
 10
>frac(.66667)
 2/3
>frac(1.33333, MIXED)
 1 1/3
>frac("5/6")
 5/6
>frac("1 2/3")
 5/3
>frac(10, 20, NO_REDUCE)
 10/20

>$f1=frac(2,3); $f2=frac(4,5);
>$f1 + $f2
 22/15
>$f1 * $f2
 8/15
>$f1 + 1.6667
 7/3
>$f2->modify_tag(MIXED)
>$f2 + 10
 54/5
>frac($ans, NORMAL) # trick to create a new fraction with different tags
 54/5
>$f1 + $f2          # Add two unlikes it goes to default mode
 22/15
>$f1**1.2
 229739670999407/373719281884655
>$f1->num**1.2
 0.614738607654485
>frac(1,2)+frac(2,5)
 9/10

>$f1=frac(5,3,NORMAL); $f2=frac(7,5);
>"$f1  $f2"
 5/3  7/5
>Math::Fraction->modify_tag(MIXED)
>"$f1  $f2"
 5/3  1 2/5
>$f1 = frac("3267893629762/32678632179820", BIG)
 1633946814881/16339316089910
>$f2 = frac("5326875886785/76893467996910", BIG)
 355125059119/5126231199794
>$f1+$f2
 3544622433410082528180951/20939777980848187019369635
>$f1*$f2
 580255459231916873949839/83759111923392748077478540
>$f1->num
 .10000093063197482237806917498797382196606
>Math::Fraction->modify_digits(15)
>$f1->num
 .1000009306319748


