13 #ifndef OPENSHOT_FRACTION_H 14 #define OPENSHOT_FRACTION_H 48 Fraction(std::map<std::string, int> mapping);
83 return static_cast<numT
>(
ToDouble() * other);
89 return static_cast<numT
>(
ToDouble() / other);
96 return static_cast<numT
>(left * right.
ToDouble());
102 return static_cast<numT
>(left / right.
ToDouble());
106 template<
class charT,
class traits>
107 std::basic_ostream<charT, traits>&
109 std::basic_ostringstream<charT, traits> s;
112 s.precision(o.precision());
113 s <<
"Fraction(" << frac.
num <<
", " << frac.den <<
")";
int num
Numerator for the fraction.
float ToFloat()
Return this fraction as a float (i.e. 1/2 = 0.5)
numT operator*(const numT &other) const
Multiplication in the form (openshot_Fraction * numeric_value)
double ToDouble() const
Return this fraction as a double (i.e. 1/2 = 0.5)
void Reduce()
Reduce this fraction (i.e. 640/480 = 4/3)
int GreatestCommonDenominator()
Calculate the greatest common denominator.
numT operator/(const numT &other) const
Division in the form (openshot_Fraction / numeric_value)
This class represents a fraction.
Fraction Reciprocal() const
Return the reciprocal as a Fraction.
int ToInt()
Return a rounded integer of the fraction (for example 30000/1001 returns 30)
This namespace is the default namespace for all code in the openshot library.
Fraction()
Default Constructor.
openshot::Fraction operator/(openshot::Fraction other)
Divide a Fraction by another Fraction.
int den
Denominator for the fraction.
openshot::Fraction operator*(openshot::Fraction other)
Multiply two Fraction objects together.