t_fract ft_fractsimplify(t_fract a) { int pgcd; t_fract result; pgcd = ft_pgcd(a.top, a.bottom); result.top = a.top / pgcd; result.bottom = a.bottom / pgcd; result.sig = a.sig; return (result); }
t_frac ft_reduce(t_frac frac) { t_frac result; int pgcd; int sign; pgcd = ft_pgcd(frac.nom, frac.denom); sign = (frac.nom * frac.denom < 0 ? -1 : 1); result.nom = ft_abs(frac.nom) / pgcd * sign; result.denom = ft_abs(frac.denom) / pgcd; return result; }