libdcp
Public Member Functions | Public Attributes | List of all members
dcp::Fraction Class Reference

A fraction (i.e. a thing with an integer numerator and an integer denominator). More...

#include <types.h>

Public Member Functions

 Fraction ()
 
 Fraction (std::string s)
 
 Fraction (int n, int d)
 
float as_float () const
 
std::string as_string () const
 

Public Attributes

int numerator = 0
 
int denominator = 0
 

Detailed Description

A fraction (i.e. a thing with an integer numerator and an integer denominator).

Definition at line 213 of file types.h.

Constructor & Destructor Documentation

◆ Fraction() [1/3]

dcp::Fraction::Fraction ( )
inline

Construct a fraction of 0/0

Definition at line 217 of file types.h.

◆ Fraction() [2/3]

Fraction::Fraction ( std::string  s)
explicit

Construct a Fraction from a string of the form <numerator> <denominator> e.g. "1 3".

Definition at line 79 of file types.cc.

◆ Fraction() [3/3]

dcp::Fraction::Fraction ( int  n,
int  d 
)
inline

Construct a fraction with a specified numerator and denominator.

Parameters
nNumerator.
dDenominator.

Definition at line 223 of file types.h.


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