! \internal Takes the fraction given by \a numerator and \a denominator and modifies the values to make sure the fraction is in irreducible form, i.e. numerator and denominator don't share any common factors which could be cancelled. */
| 6864 | factors which could be cancelled. |
| 6865 | */ |
| 6866 | void QCPAxisTickerPi::simplifyFraction(int &numerator, int &denominator) const |
| 6867 | { |
| 6868 | if (numerator == 0 || denominator == 0) |
| 6869 | return; |
| 6870 | |
| 6871 | int num = numerator; |
| 6872 | int denom = denominator; |
| 6873 | while (denom != 0) // euclidean gcd algorithm |
| 6874 | { |
| 6875 | int oldDenom = denom; |
| 6876 | denom = num % denom; |
| 6877 | num = oldDenom; |
| 6878 | } |
| 6879 | // num is now gcd of numerator and denominator |
| 6880 | numerator /= num; |
| 6881 | denominator /= num; |
| 6882 | } |
| 6883 | |
| 6884 | /*! \internal |
| 6885 |
nothing calls this directly
no outgoing calls
no test coverage detected