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(); } } }
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; } else if (setS=="no" || setS=="n") { break; } else { cout << "Invalid entry" << endl << endl; continue; } } else { setS.clear(); cout << "Turn on percentages? "; std::getline(cin, setS); if (setS=="yes" || setS=="y") { user.percentOn(); break; } else if (setS=="no" || setS=="n") { break; } else { cout << "Invalid entry" << endl << endl; continue; } } } for (;;) { setS.clear(); if (user.getShowDigits()) { cout << "Hide number stats? "; std::getline(cin, setS); if (setS=="yes" || setS=="y") { user.showDigitsOff(); break; } else if (setS=="no" || setS=="n") { break; } else { cout << "Invalid entry" << endl << endl; continue; } } else { cout << "Show number stats? "; std::getline(cin, setS); if (setS=="yes" || setS=="y") { user.showDigitsOn(); break; } else if (setS=="no" || setS=="n") { break; } else { cout << "Invalid entry" << endl << endl; continue; } } } cout << endl << endl; }