don't return negative percentage when max < 0
This commit is contained in:
parent
90e1775a2b
commit
3cc3390f17
|
@ -358,9 +358,9 @@ public class RestNodesAction extends AbstractCatAction {
|
|||
* Calculate the percentage of {@code used} from the {@code max} number.
|
||||
* @param used The currently used number.
|
||||
* @param max The maximum number.
|
||||
* @return 0 if {@code max} is 0. Otherwise 100 * {@code used} / {@code max}.
|
||||
* @return 0 if {@code max} is <= 0. Otherwise 100 * {@code used} / {@code max}.
|
||||
*/
|
||||
private short calculatePercentage(long used, long max) {
|
||||
return max == 0 ? 0 : (short)((100d * used) / max);
|
||||
return max <= 0 ? 0 : (short)((100d * used) / max);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue