Sorting Fractions

Hello.
I have to sort n fractions given their numerator(a1-an) and denominator(b1-bn).
My question is:
Is it risky to:
have a
1
2
3
4
5
struct fraction
{
  int numerator,denominator;
  long double division;
};

and store division=(long double)numerator/denominator;?
Beacause i want to test for equality i just wonder if the computer goes to the 1/2 fraction and gets 0.5 but when it goes to 2/4 it gets 0.4999999.. than htey wont be equal. What do you think?
usually something like a==b is not a good idea if you know the values wont be precise.
you better use (a-b)<threshold
wow never thought of it ;p thanks!
Topic archived. No new replies allowed.