20 General utilities library [utilities]

20.16 Compile-time rational arithmetic [ratio]

20.16.4 Arithmetic on ratios [ratio.arithmetic]

Table 58: Expressions used to perform ratio arithmetic [tab:ratio.arithmetic]
Type
Value of X
Value of Y
ratio_­add<R1, R2>
R1​::​num * R2​::​den +
R1​::​den * R2​::​den
R2​::​num * R1​::​den
ratio_­subtract<R1, R2>
R1​::​num * R2​::​den -
R1​::​den * R2​::​den
R2​::​num * R1​::​den
ratio_­multiply<R1, R2>
R1​::​num * R2​::​num
R1​::​den * R2​::​den
ratio_­divide<R1, R2>
R1​::​num * R2​::​den
R1​::​den * R2​::​num