0 or $int2>0) return (14+floor(log10(max($int1,$int2)))*8*$adf); } #gcf function function gcf($int1, $int2) { $n=max(abs($int1),abs($int2)); for ($i=1; $i<=$n;$i++) { if (($int1 % $i)==0 and ($int2 % $i)==0) $g=$i; } return $g; } #function to convert an improper fraction to a mixed number function fr2mixed(&$a,&$b,&$c) { if(abs($b)>=abs($c)){ $sign=$b/abs($b); $b=abs($b); while ($b>=$c) {$a=$a+1; $b=$b-$c;} $a=$sign*$a;} } #function to convert a mixed number to a fraction function mixed2frac(&$a,&$b,&$c) { if ($a!=0) { $sign=$a/abs($a); $a=abs($a); $b=$a*$c+$b; $a=0; $b=$sign*$b; } } #function that simplifies; takes two integers function simpl(&$n,&$d) { $g=gcf($n,$d); $n=$n/$g; $d=$d/$g; } ?> Fraction Worksheet Answer Key

Answer Key for Fraction Worksheet

\n"; for ($c=1; $c<=$zcol; $c++) { $letter=chr($c+96); $x=($r-1)*$zcol + $c-1; #$x= cell number>> echo ""; $cells++; } echo "\n"; } ?>
"; switch ($zop) { case "si": $num=$z[$cells][1]/gcf($z[$cells][1],$z[$cells][2]); $den=$z[$cells][2]/gcf($z[$cells][1],$z[$cells][2]); $w1=f_line($num,$den, $zfl); echo ""; break; case "eq": $w1=f_line($z[$cells][1],$z[$cells][2], $zfl); $w2=f_line($z[$cells][3],$z[$cells][4], $zfl); echo ""; break; case "fr2mi": fr2mixed($z[$cells][3], $z[$cells][1],$z[$cells][2]); if (!$zdontsimplifyanswers) simpl($z[$cells][1],$z[$cells][2]); $w1=f_line($z[$cells][1],$z[$cells][2], $zfl); echo ""; if ($z[$cells][1]==0) echo ""; else { echo "";} break; case "mi2fr": mixed2frac($z[$cells][1],$z[$cells][2],$z[$cells][3]); if (!$zdontsimplifyanswers) simpl($z[$cells][2],$z[$cells][3]); $w1=f_line($z[$cells][3],$z[$cells][2], $zfl); echo ""; break; } echo "
$r$letter.  

$num

$den

"; echo $z[$cells][1]; echo "

"; echo "

"; echo $z[$cells][2]; echo "

 = 

"; echo $z[$cells][3]; echo "

"; echo $z[$cells][4]; echo "

"; echo $z[$cells][3]; echo "  

"; echo $z[$cells][1]; echo "

"; echo $z[$cells][2]; echo"

"; echo $z[$cells][2]; echo "

"; echo $z[$cells][3]; echo "