15 #ifndef __FRACTION_H__ 16 #define __FRACTION_H__ 30 static int_least64_t gcd(int_least64_t a, int_least64_t b)
33 if (b > a) { bp = b; b = a; a = bp; }
35 bp = b; b = a % b; a = bp;
38 return (a >= 0 ? a : -a);
72 void set(
int z,
int n) {
183 const int sign = (val.
_numerator >= 0 ? 1 : -1);
238 return static_cast<int>(result);
246 const int i = str.indexOf(
'/');
247 return (i == -1) ?
Fraction(str.toInt(), 1) :
Fraction(str.leftRef(i).toInt(), str.midRef(i+1).toInt());
249 operator QVariant()
const {
return QVariant::fromValue(*
this); }
int numerator() const
Definition: fraction.h:62
Fraction reduced() const
Definition: fraction.h:101
Fraction operator/(const Fraction &v) const
Definition: fraction.h:202
int denominator() const
Definition: fraction.h:63
QString print() const
Definition: fraction.h:243
static Fraction fromTicks(int ticks)
Definition: fraction.h:210
Fraction & operator/=(const Fraction &val)
Definition: fraction.h:181
QString toString() const
Definition: fraction.h:244
bool operator<(const Fraction &val) const
Definition: fraction.h:109
bool isZero() const
Definition: fraction.h:77
Fraction & operator*=(const Fraction &val)
Definition: fraction.h:167
constexpr Fraction()
Definition: fraction.h:59
bool operator>(const Fraction &val) const
Definition: fraction.h:124
static Fraction fromString(const QString &str)
Definition: fraction.h:245
bool identical(const Fraction &v) const
Definition: fraction.h:84
int_least64_t _denominator
Definition: fraction.h:50
void setNumerator(int v)
Definition: fraction.h:67
void reduce()
Definition: fraction.h:95
bool operator<=(const Fraction &val) const
Definition: fraction.h:114
bool operator>=(const Fraction &val) const
Definition: fraction.h:119
constexpr Fraction(int z, int n)
Definition: fraction.h:60
bool operator!=(const Fraction &val) const
Definition: fraction.h:134
bool isNotZero() const
Definition: fraction.h:78
Definition: aeolus.cpp:26
Fraction operator-() const
Definition: fraction.h:200
Fraction operator*(const Fraction &v) const
Definition: fraction.h:201
Fraction operator-(const Fraction &v) const
Definition: fraction.h:199
Fraction & operator+=(const Fraction &val)
Definition: fraction.h:141
int_least64_t & rdenominator()
Definition: fraction.h:65
void setDenominator(int v)
Definition: fraction.h:68
int_least64_t & rnumerator()
Definition: fraction.h:64
Fraction & operator*=(int val)
Definition: fraction.h:175
static int division
Definition: mscore.h:357
int ticks() const
Definition: fraction.h:228
bool isValid() const
Definition: fraction.h:80
Definition: fraction.h:46
bool operator==(const Fraction &val) const
Definition: fraction.h:129
Fraction & operator-=(const Fraction &val)
Definition: fraction.h:154
Fraction absValue() const
Definition: fraction.h:89
int_least64_t _numerator
Definition: fraction.h:49
Fraction operator+(const Fraction &v) const
Definition: fraction.h:198
static Fraction eps()
A very small fraction, corresponds to 1 MIDI tick.
Definition: fraction.h:222