Equivalent fractions can have different representations: 6/15 and 2/5 denote the same rational number. Normalization divides the numerator and denominator by their greatest common divisor, giving a representation with fewer factors that can also help avoid overflow during arithmetic. section 10.2.2
rat rat_get_normal(rat x) [[__unsequenced__]] {
size_t c = gcd(x.num, x.denom);
x.num /= c;
x.denom /= c;
return x;
}
rat_get_normal computes the greatest common divisor and divides both fields by it. section 10.2.2
Rational multiplication and addition can first compute a result representation, then normalize it before returning it. section 10.2.2




















