There's a module (I never used) called Math::Fraction which seems to do the trick. It even handles mixed fractions:
use Math::Fraction; $a = frac("10 3/4"); $b = frac("1/2"); $c = frac("2/5"); $d = $a * $b + $c; print("$d\n");
It supports:
+ - / * + += -= *= /= ++ -- abs <=> == != < <= > >= ** sqrt
and has some useful conversion methods.
In reply to Re: Arithmetic with fractions
by ikegami
in thread Arithmetic with fractions
by algonquin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |