in reply to Arithmetic with fractions
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Arithmetic with fractions
by initself (Monk) on Feb 07, 2008 at 19:42 UTC |