I was looking to see if there was a variable that could store a ratio. Then I saw the header <ratio> and thought cool. But upon closer look it seems that this does not hold a ratio but rather a fraction. 2/3 is not the same as 2:3.
Am I mistaken? Can someone enlighten me on this subject?
No, you are not mistaken. It holds a rational number, not a "ratio" per se. Rational numbers are more generally useful. But the rational numbers of <ratio> are set at compile time. So you probably want to make your own ratio class.
@keskiverto, I had initially assumed that <ratio> would be something more useful than that. Taking a peek at the docs, I modified my answer just before you posted! But it's slightly more than just two integers since it will reduce them to lowest terms (so you don't always get exactly the same integers back; just the same ratio).
OK, so I see. My error was in the name. It is not an actual ratio variable, which might have been cool actually. A variable that could be modified as needed...
1 2 3 4 5 6
ratio r1 = 2:3;
ratio r2 = 2:5;
ratio r3 = r1 + r2;
cout << r3;