You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Especially, if each value considered in for-loop is 0, calculated maximum is Double.MIN_VALUE, because Double.MIN_VALUE > 0.
However, replacing Double.MIN_VALUE with Double.NEGATIVE_INFINITY cause wrong calculation. In such case maxQ(8) is Double.NEGATIVE_INFINITY and whole calculation fails.
Summary: maximum calculation is implemented wrong or at least misleading. It hard to me to propose a solution because it is not clear to me what is expected to be maxQ(8)
I checked the code and I found the same issue as described above. Please use double maxValue = Double.NEGATIVE_INFINITY otherwise condition is never satisfied when it should be
if (value > maxValue)
maxValue = value;
While testing your code, I found that having double maxValue = Double.NEGATIVE_INFINITY throws off the whole calculation. Using Double.MIN_VALUE should fix things. Well, it runs perfect using MIN_VALUE anyway.
Activity
ahsan-ikram commentedon Jun 18, 2018
I checked the code and I found the same issue as described above. Please use double maxValue = Double.NEGATIVE_INFINITY otherwise condition is never satisfied when it should be
if (value > maxValue)
maxValue = value;
technobium commentedon Jun 28, 2018
Thanks for the observation. I changed the code.
SimonAsenime commentedon Aug 2, 2018
While testing your code, I found that having double maxValue = Double.NEGATIVE_INFINITY throws off the whole calculation. Using Double.MIN_VALUE should fix things. Well, it runs perfect using MIN_VALUE anyway.