Fix minor bug in progress calculation
This commit is contained in:
parent
def77613c6
commit
c4d48e982a
1 changed files with 6 additions and 4 deletions
|
@ -18,12 +18,14 @@ long long FactorizationController::curFactNumber() const {
|
||||||
|
|
||||||
int FactorizationController::progress() const {
|
int FactorizationController::progress() const {
|
||||||
// If the original number is set to 0, the computation wasn't yet initialized / was reset.
|
// If the original number is set to 0, the computation wasn't yet initialized / was reset.
|
||||||
if (m_originalNumber == 0)
|
// If the current factor is at 2, the computation has just started, return early to avoid
|
||||||
|
// zero division issues.
|
||||||
|
if (m_originalNumber == 0 || m_currentFactor <= 2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// If current factor is at or below 2 already, we must be done,
|
// If the current number being factorized is 1, we must be done, all factors were found
|
||||||
// stopFactor can never be less than 2, that makes no sense.
|
// Alternatively, we're also done when the current factor passes the stop factor.
|
||||||
if (m_currentFactNumber == 1 || m_currentFactor <= 2 || m_currentFactor > m_stopFactor)
|
if (m_currentFactNumber == 1 || m_currentFactor > m_stopFactor)
|
||||||
return 100;
|
return 100;
|
||||||
|
|
||||||
// Determine the progress based on the current factor, in comparison to stop factor.
|
// Determine the progress based on the current factor, in comparison to stop factor.
|
||||||
|
|
Loading…
Add table
Reference in a new issue