#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 |
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.
|
inline |
Default constructor. Initializes to 0/1 or 0
Definition at line 41 of file sbFraction.h.
|
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.
|
inline |
Initializes the fraction given a whole number, numerator, and denominator
Definition at line 56 of file sbFraction.h.
|
inline |
Returns the denominator portion of the fraction
Definition at line 144 of file sbFraction.h.
|
inline |
Definition at line 149 of file sbFraction.h.
|
inline |
Compares this fraction with another for equality Also deal with fractions that are not simplified
aOther | The other fraction to compare |
Definition at line 69 of file sbFraction.h.
|
inline |
Compares if this fraction is less than the "other"
aOther | The secondary fraction to compare |
Definition at line 83 of file sbFraction.h.
|
inline |
Returns the numerator portion of the fraction given an improper fraction representation
Definition at line 136 of file sbFraction.h.
|
inline |
Returns a floating point representation of the fraction
Definition at line 91 of file sbFraction.h.
|
inline |
Less than operator.
Definition at line 108 of file sbFraction.h.
|
inline |
Less than or equal operator.
Definition at line 126 of file sbFraction.h.
|
inline |
Greater than operator.
Definition at line 99 of file sbFraction.h.
|
inline |
Greater than or equal operator.
Definition at line 117 of file sbFraction.h.