OpenShot Library | libopenshot  0.1.9
Public Member Functions | Public Attributes | List of all members
openshot::Fraction Class Reference

This class represents a fraction. More...

#include <Fraction.h>

Public Member Functions

 Fraction ()
 Default Constructor. More...
 
 Fraction (int num, int den)
 Constructor with numerator and denominator. More...
 
int GreatestCommonDenominator ()
 Calculate the greatest common denominator. More...
 
Fraction Reciprocal ()
 Return the reciprocal as a Fraction. More...
 
void Reduce ()
 Reduce this fraction (i.e. 640/480 = 4/3) More...
 
double ToDouble ()
 Return this fraction as a double (i.e. 1/2 = 0.5) More...
 
float ToFloat ()
 Return this fraction as a float (i.e. 1/2 = 0.5) More...
 
int ToInt ()
 Return a rounded integer of the fraction (for example 30000/1001 returns 30) More...
 

Public Attributes

int den
 Denominator for the fraction. More...
 
int num
 Numerator for the fraction. More...
 

Detailed Description

This class represents a fraction.

Fractions are often used in video editing to represent ratios and rates, for example: pixel ratios, frames per second, timebase, and other common ratios. Fractions are preferred over decimals due to their increased precision.

Definition at line 42 of file Fraction.h.

Constructor & Destructor Documentation

◆ Fraction() [1/2]

Fraction::Fraction ( )

Default Constructor.

Definition at line 33 of file Fraction.cpp.

◆ Fraction() [2/2]

Fraction::Fraction ( int  num,
int  den 
)

Constructor with numerator and denominator.

Definition at line 36 of file Fraction.cpp.

Member Function Documentation

◆ GreatestCommonDenominator()

int Fraction::GreatestCommonDenominator ( )

Calculate the greatest common denominator.

Definition at line 56 of file Fraction.cpp.

◆ Reciprocal()

Fraction Fraction::Reciprocal ( )

Return the reciprocal as a Fraction.

Definition at line 81 of file Fraction.cpp.

◆ Reduce()

void Fraction::Reduce ( )

Reduce this fraction (i.e. 640/480 = 4/3)

Definition at line 71 of file Fraction.cpp.

◆ ToDouble()

double Fraction::ToDouble ( )

Return this fraction as a double (i.e. 1/2 = 0.5)

Definition at line 46 of file Fraction.cpp.

◆ ToFloat()

float Fraction::ToFloat ( )

Return this fraction as a float (i.e. 1/2 = 0.5)

Definition at line 41 of file Fraction.cpp.

◆ ToInt()

int Fraction::ToInt ( )

Return a rounded integer of the fraction (for example 30000/1001 returns 30)

Definition at line 51 of file Fraction.cpp.

Member Data Documentation

◆ den

int openshot::Fraction::den

Denominator for the fraction.

Definition at line 45 of file Fraction.h.

◆ num

int openshot::Fraction::num

Numerator for the fraction.

Definition at line 44 of file Fraction.h.


The documentation for this class was generated from the following files: