This content has been marked as final. Show 2 replies
I haven't tested this, but for a workaround you might try
This will (should) force the division to be computed using doubles rather than ints; x/0.0 will evaluate to Double.NaN in java, without throwing an exception. Note that this computation will give slightly different results in some other cases, as the integer division you were using before will always result in an int (by truncation); whereas this will give you double precision division. In most cases, the latter will actually be what you want.
progressBar.progressProperty().bind( Bindings.when(denominator.isEqualTo(0)) .then(0) .otherwise(numerator.divide(denominator.doubleValue())));
I tried out that solution, and it works great! Thank you!