本文整理汇总了C++中settings::getPercent方法的典型用法代码示例。如果您正苦于以下问题:C++ settings::getPercent方法的具体用法?C++ settings::getPercent怎么用?C++ settings::getPercent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类settings
的用法示例。
在下文中一共展示了settings::getPercent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: displayNumber
void displayNumber(bigNumber &bn, settings &user, bool exact, bool stats)
{
if (exact)
bn.printNumber();
else
{
int actualDigits = bn.getDigitCount() - (PRECISION-bn.getDecimalCount());
if (user.getPercent())
{
bn.printPercent(user.getRound());
}
else
{
bn.printNumber(user.getRound());
}
if (user.getShowDigits() && stats==true)
{
cout << endl;
cout << "Digits: ";
if (bn<1 && bn > -1 && bn != 0)
cout << actualDigits - 1;
else cout << actualDigits;
cout << "\nDecimal places: " << bn.getDecimalCount();
cout << "\nBase: " << bn.getBase();
}
}
}
示例2: modifySettings
void modifySettings(settings &user)
{
cout << endl;
string setI;
string setS;
bool invalid=false;
int intSet=0;
do
{
intSet=0;
invalid=false;
setI.clear();
cout << "Enter desired precision: ";
std::getline(cin, setI);
for (int i=0; i<setI.size(); i++)
{
int target = setI.size()-i-1;
if (checkNumber(setI[target]) < 0 || checkNumber(setI[target]) > 9)
{
cout << "Invalid entry" << endl << endl;
invalid=true;
break;
}
else intSet += (checkNumber(setI[target]) * pow(10, i));
}
if (invalid==false)
{
if (intSet>PRECISION)
{
cout << "Invalid entry (precision must be between 0 and " << PRECISION << ")" << endl << endl;
invalid=true;
}
else
{
user.setRound(intSet);
}
}
} while (invalid==true);
do
{
intSet=0;
invalid=false;
setI.clear();
cout << "Enter desired base: ";
std::getline(cin, setI);
for (int i=0; i<setI.size(); i++)
{
int target = setI.size()-i-1;
if (checkNumber(setI[target]) < 0 || checkNumber(setI[target]) > 9 )
{
cout << "Invalid entry" << endl << endl;
invalid=true;
break;
}
else intSet += (checkNumber(setI[target]) * pow(10, i));
}
if (invalid==false)
{
if (intSet < 2 || intSet > 36)
{
cout << "Invalid entry (base must be between 2 and 36)" << endl << endl;
invalid=true;
}
else
{
user.setBase(intSet);
}
}
} while (invalid==true);
for (;;)
{
if (user.getPercent())
{
setS.clear();
cout << "Turn off percentages? ";
std::getline(cin, setS);
if (setS=="yes" || setS=="y")
{
user.percentOff();
break;
}
//.........这里部分代码省略.........