本文整理汇总了C++中Number::denominator方法的典型用法代码示例。如果您正苦于以下问题:C++ Number::denominator方法的具体用法?C++ Number::denominator怎么用?C++ Number::denominator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Number
的用法示例。
在下文中一共展示了Number::denominator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operatorHelper
bool operator<(Number l, Number r)
{
int lnum = l.numerator();
int lden = l.denominator();
int rnum = r.numerator();
int rden = r.denominator();
if (lnum < 0 && rnum >= 0)
return true;
if (rnum <= 0 && lnum >=0)
return false;
return operatorHelper(abs(lnum), abs(lden), abs(rnum), abs(rden));
}
示例2: prod
Number operator*( Number l, Number r)
{
int lnum = l.numerator();
int lden = l.denominator();
int rnum = r.numerator();
int rden = r.denominator();
// cross factor
int factor1 = gcdFunction(lnum, rden);
int factor2 = gcdFunction(rnum, lden);
lnum /= factor1;
rden /= factor1;
rnum /= factor2;
lden /= factor2;
Number prod(lnum*rnum, rden*lden);
return prod;
}
示例3: printRowAt
void Matrix::printRowAt(int row)
{
cout << "|";
for (int j = 0; j < at(row).size() ; j++)
{
Number num = at(row).at(j);
// if positive
if (num >= Number())
{
cout << " ";
}
// if whole number
if (num.denominator() == 1)
{
cout << " " << num.numerator() << " ";
}
else
{
cout << " " << num << " ";
}
}
cout << "|";
}
示例4: inverse
Number operator/( Number l, Number r)
{
Number inverse(r.denominator(), r.numerator());
return l*inverse;
}
示例5: return
bool operator==( Number l, Number r ) {
return (l.numerator() == r.numerator() && l.denominator() == r.denominator());
}
示例6: denom
// copy constructor
Number::Number(const Number &c) :
num(c.numerator()), denom(c.denominator())
{}