20 #include "IRational.h"
24 namespace com {
namespace avpkit {
namespace core
27 IRational::IRational()
31 IRational::~IRational()
43 int64_t den, int64_t max)
45 return (dst ? dst->
reduce(num, den, max) : 0);
75 return newBase->
rescale(origValue, origBase);
117 if (!origBase || !newBase)
119 return newBase->
rescale(origValue, origBase, rounding);
124 int32_t dstNumerator,
125 int32_t dstDenominator,
126 int32_t srcNumerator,
127 int32_t srcDenominator,
131 dstNumerator, dstDenominator,
132 srcNumerator, srcDenominator,
static void init()
Internal Only.
This class wraps represents a Rational number for the AVPKit.
static int32_t sReduce(IRational *dst, int64_t num, int64_t den, int64_t max)
Reduce a fraction to it's lowest common denominators.
virtual int32_t compareTo(IRational *other)=0
Compare a rational to this rational.
virtual IRational * divide(IRational *arg)=0
Divides this rational by arg.
static IRational * make()
Get a new rational that will be set to 0/0.
static IRational * sMultiply(IRational *a, IRational *b)
Multiples a by b.
virtual int64_t rescale(int64_t origValue, IRational *origBase)=0
Takes a value scaled in increments of origBase and gives the equivalent value scaled in terms of this...
virtual int32_t reduce(int64_t num, int64_t den, int64_t max)=0
Reduce a fraction to it's lowest common denominators.
static int64_t sRescale(int64_t origValue, IRational *origBase, IRational *newBase)
Takes a value scaled in increments of origBase and gives the equivalent value scaled in terms of this...
static IRational * sSubtract(IRational *a, IRational *b)
Subtracts a from b.
virtual IRational * add(IRational *arg)=0
Adds arg to this rational.
static int32_t sCompareTo(IRational *a, IRational *b)
Compare two rationals.
virtual IRational * multiply(IRational *arg)=0
Multiplies this number by arg.
virtual IRational * subtract(IRational *arg)=0
Subtracts arg from this rational.
static IRational * sAdd(IRational *a, IRational *b)
Adds a to b.
static IRational * sDivide(IRational *a, IRational *b)
Divides a by b.
virtual int64_t rescale(int64_t origValue, IRational *origBase)
Takes a value scaled in increments of origBase and gives the equivalent value scaled in terms of this...
WARNING: Do not use logging in this class, and do not set any static file variables to values other t...