## WeBWorK Main Forum

### Re: mod (%) irregularities ?

by Alex Jordan -
Number of replies: 0
If you load contextFraction.pl, then there is a Fraction Context with a Math Object Fraction that automatically reduces fractions (this is a flag that can be toggled.)

Context("Fraction.pl");
$fraction = Fraction($numer,$denom); I find it useful to then return to the Numeric Context Context("Numeric");$fraction = Compute("$fraction"); Or students might get error messages implying they should be entering a fraction, even when$fraction is actually a whole number.

If you have a Fraction Math Object and wish to extract the reduced numerator or denominator, first create an array from $f: @g =$f->value;
And then $g[0] is the numerator and$g[1] is the denominator. These are perl integers, not Math Objects, so you might want to set something like
$num = Compute($g[0]);
$den= Compute($g[1]);