sbFraction Class Reference

#include <sbFraction.h>

Public Member Functions

 sbFraction ()
 
 sbFraction (PRUint32 aNumerator, PRUint32 aDenominator=1)
 
 sbFraction (PRUint32 aWholeNumber, PRUint32 aNumerator, PRUint32 aDenominator)
 
bool IsEqual (sbFraction const &aOther) const
 
bool IsLessThan (sbFraction const &aOther) const
 
 operator double () const
 
PRBool operator> (const sbFraction &aFraction)
 
PRBool operator< (const sbFraction &aFraction)
 
PRBool operator>= (const sbFraction &aFraction)
 
PRBool operator<= (const sbFraction &aFraction)
 
PRUint32 Numerator () const
 
PRUint32 Denominator () const
 
void GetProperFraction (PRUint32 &aWhole, PRUint32 &aNumerator, PRUint32 &aDenominator) const
 

Detailed Description

This is a simple class to represent fractions. Some media attributes are best represented as fractions rather than floating point values which can introduce rounding errors. Supports comparisons but no math operations

Definition at line 35 of file sbFraction.h.

Constructor & Destructor Documentation

sbFraction::sbFraction ( )
inline

Default constructor. Initializes to 0/1 or 0

Definition at line 41 of file sbFraction.h.

sbFraction::sbFraction ( PRUint32  aNumerator,
PRUint32  aDenominator = 1 
)
inline

Initialize the fraction given a numerator and optional denominator. If the denominator is not specified it defaults to one and allows this to serve as a whole number constructor

Definition at line 49 of file sbFraction.h.

sbFraction::sbFraction ( PRUint32  aWholeNumber,
PRUint32  aNumerator,
PRUint32  aDenominator 
)
inline

Initializes the fraction given a whole number, numerator, and denominator

Definition at line 56 of file sbFraction.h.

Member Function Documentation

PRUint32 sbFraction::Denominator ( ) const
inline

Returns the denominator portion of the fraction

Definition at line 144 of file sbFraction.h.

Here is the caller graph for this function:

void sbFraction::GetProperFraction ( PRUint32 &  aWhole,
PRUint32 &  aNumerator,
PRUint32 &  aDenominator 
) const
inline

Definition at line 149 of file sbFraction.h.

bool sbFraction::IsEqual ( sbFraction const &  aOther) const
inline

Compares this fraction with another for equality Also deal with fractions that are not simplified

Parameters
aOtherThe other fraction to compare
Returns
true if the two fraction are equal

Definition at line 69 of file sbFraction.h.

Here is the caller graph for this function:

bool sbFraction::IsLessThan ( sbFraction const &  aOther) const
inline

Compares if this fraction is less than the "other"

Parameters
aOtherThe secondary fraction to compare
Returns
true if this fraction is less than aOther

Definition at line 83 of file sbFraction.h.

Here is the caller graph for this function:

PRUint32 sbFraction::Numerator ( ) const
inline

Returns the numerator portion of the fraction given an improper fraction representation

Definition at line 136 of file sbFraction.h.

Here is the caller graph for this function:

sbFraction::operator double ( ) const
inline

Returns a floating point representation of the fraction

Definition at line 91 of file sbFraction.h.

PRBool sbFraction::operator< ( const sbFraction aFraction)
inline

Less than operator.

Definition at line 108 of file sbFraction.h.

PRBool sbFraction::operator<= ( const sbFraction aFraction)
inline

Less than or equal operator.

Definition at line 126 of file sbFraction.h.

PRBool sbFraction::operator> ( const sbFraction aFraction)
inline

Greater than operator.

Definition at line 99 of file sbFraction.h.

PRBool sbFraction::operator>= ( const sbFraction aFraction)
inline

Greater than or equal operator.

Definition at line 117 of file sbFraction.h.


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