Let's say I have two fractions: a/b and c/d, where a,b,c,d are all integers greater than 0. Is it safe to check their equality using the following function?:
bool are_equal_fractions(int a, int b, int c, int d) {
return (static_cast<double>(a) / b == static_cast<double>(c) / d);
}
According to another question: can I compare two fractions if both have denominator with power of 2 I can use this method when both denominators are powers of 2, but what about more generic case?